:root{
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;

  --botBubble: #f3f4f6;
  --userBubble: #0b0b0c;
}

*{ box-sizing:border-box; }
html, body { height: 100dvh; overflow-x: hidden;}
body{
  margin:0;
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: var(--text);
}

/* ===== Layout (giá»¯ nhÆ° báº£n fullscreen) ===== */
.fs-shell{ height:100vh; display:flex; gap:14px; padding:14px; }
.fs-sidebar{
  width:360px;
  min-width:360px;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:18px;
  padding:14px;
  display:flex; flex-direction:column;
  overflow:auto;
}
.brand{ display:flex; align-items:center; gap:12px; padding:6px 6px 12px;}
.brand-badge{width: 55px;height: 55px;border-radius:14px;display:grid;place-items:center;font-weight:800;color:#fff;}
.brand-title{ font-weight:800; }
.brand-sub{ color:var(--muted); font-size:.92rem; margin-top:2px; }
.intro{ padding:12px 6px; }
.intro-title,.suggest-title{ font-weight:800; font-size:13px; margin-bottom:6px; }
.intro-text,.hint{ color:var(--muted); font-size:13px; line-height:1.4; }
.suggest{ padding:10px 6px 6px; border-top:1px solid var(--border); }
.chips{ display:flex; flex-wrap:wrap; gap:8px; }
.chip{
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  border-radius:999px;
  padding: 5px 10px;
  font-size:13px;
  cursor:pointer;
  margin-bottom: 5px;
  display: inline-block;
}
.chip:hover{ background:#f3f4f6; }

.fs-main{
  flex:1 1 auto;
  background:var(--card);
  border:1px solid var(--border);
  border-radius:18px;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.fs-topbar{
  padding:12px 14px;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.fs-h1{ font-weight:900; font-size:14px; }
.fs-h2{ color:var(--muted); font-size:13px; margin-top:2px; }

.fs-chat{
  flex:1 1 auto;
  padding:14px;
  overflow:auto;
  background:#fff;
}

/* ===== Message UI giá»‘ng áº£nh ===== */
.msg{
  display:flex;
  width:100%;
  margin: 10px 0;
}

.msg.bot{ justify-content:flex-start; }
.msg.user{ justify-content:flex-end; }

.bubble{
  max-width: 72%;
  padding: 10px 12px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.35;
  /* white-space: pre-wrap; */
}
.bubble br {
  display: none;
}

/* bot bubble xÃ¡m, canh trÃ¡i */
.msg.bot .bubble{
  background: var(--botBubble);
  color: var(--text);
  border-bottom-left-radius: 8px;
}

/* user bubble Ä‘en, canh pháº£i */
.msg.user .bubble{
  background: var(--userBubble);
  color: #fff;
  border-bottom-right-radius: 8px;
  box-shadow: 0 10px 22px rgba(0,0,0,.18);
}

/* ===== Typing bubble (3 cháº¥m nháº£y) ===== */
.typing-row{
  display:flex;
  justify-content:flex-start;
  margin: 10px 0;
}

.typing-bubble{
  background: var(--botBubble);
  border-radius: 18px;
  border-bottom-left-radius: 8px;
  padding: 10px 12px;
  display:flex;
  align-items:center;
  gap: 6px;
  min-width: 64px;
}

.dot{
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c4c7cc;
  animation: bounce 1.1s infinite ease-in-out;
}
.dot:nth-child(2){ animation-delay: .15s; }
.dot:nth-child(3){ animation-delay: .30s; }

@keyframes bounce{
  0%, 80%, 100%{ transform: translateY(0); opacity:.55; }
  40%{ transform: translateY(-5px); opacity:1; }
}

/* compose */
.fs-compose{
  padding:12px 14px;
  border-top:1px solid var(--border);
  background:#fff;
}
.compose-row{ display:flex; gap:10px; align-items:center; }
.compose-input{
  flex:1; height:44px;
  border-radius:999px;
  border:1px solid var(--border);
  padding:0 14px;
  outline:none;
  font-size:14px;
  background:#f9fafb;
}
.compose-input:focus{ background:#fff; border-color:#d1d5db; }
.compose-send{
  width:44px; height:44px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  display:grid; place-items:center;
  color:#111827;
}
.compose-send:hover{ background:#f3f4f6; }

/* Responsive */
@media (max-width: 992px){
  .fs-shell{ flex-direction:column; }
  .fs-sidebar{ width:100%; max-width:100%; }
}
.chips-group { display:flex; flex-direction:column; gap:14px; }
.group-title{
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 8px;
  color: #111827;
}
/* Formatting inside bot bubble */
.msg.bot .bubble h1, .msg.bot .bubble h2, .msg.bot .bubble h3{
  margin: 0 0 8px 0;
  font-weight: 900;
}
.msg.bot .bubble h2{ font-size: 15px; }
.msg.bot .bubble h3{ font-size: 14px; }

.msg.bot .bubble p{ margin: 0 0 8px 0; }
.msg.bot .bubble p:last-child{ margin-bottom: 0; }

.msg.bot .bubble .ul, .msg.bot .bubble .ol{
  margin: 6px 0 10px 0;
  padding-left: 18px;
}
.msg.bot .bubble .ul-li, .msg.bot .bubble .ol-li{
  margin: 4px 0;
}
.msg.bot .bubble .ol{ list-style: none; padding-left: 0; }
.msg.bot .bubble .ol-li{
  display:flex; gap:8px; align-items:flex-start;
}
.msg.bot .bubble .ol-n{
  min-width: 22px;
  font-weight: 800;
  color: #111827;
}
.msg.bot .bubble .note{
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
}
/* ===== Document-like formatting inside BOT bubble ===== */
.msg.bot .bubble{
  background: #f3f4f6;
  max-width: 86%;
  padding: 14px 16px;
  /* text-align: left; */
}

.msg.bot .bubble .doc-h1{
  font-size: 16px;
  font-weight: 900;
  margin: 0 0 10px 0;
}
.msg.bot .bubble .doc-h2{
  font-size: 15px;
  font-weight: 900;
  margin: 12px 0 8px 0;
}
.msg.bot .bubble .doc-p{
  margin: 0 0 10px 0;
  line-height: 1.55;
}

.msg.bot .bubble .doc-hr{
  border: none;
  border-top: 1px solid #d6d9de;
  margin: 14px 0;
}

.msg.bot .bubble .doc-ul{
  margin: 0 0 10px 0;
  padding-left: 18px;
}
.msg.bot .bubble .doc-ul-nested{
  margin-top: 6px;
  padding-left: 18px;
}
.msg.bot .bubble .doc-li{
  margin: 6px 0;
  line-height: 1.55;
}
/* ===== Mobile upgrade patch (append at end) ===== */
:root{
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* Fix 100vh issues on mobile browser + keyboard */
.fs-shell{
  min-height: 100dvh;
  height: 100dvh;            /* modern browsers */
  padding: 12px;
}

/* Desktop sidebar only */
.fs-sidebar-desktop{ display:block; }
@media (max-width: 992px){
  .fs-sidebar-desktop{ display:none; }
}

/* Mobile: main full screen, topbar sticky */
@media (max-width: 992px){
  .fs-shell{
    flex-direction: column;
    gap: 12px;
    padding: 0;              /* full bleed like app */
  }

  .fs-main{
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    height: 100dvh;
  }

  .fs-topbar{
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    padding-top: calc(12px + var(--safe-top));
  }

  .fs-chat{
    padding: 12px 12px 10px;
    background: #fff;
  }

  .bubble{
    max-width: 92%;
    font-size: 14px;
    line-height: 1.45;
    text-align: left;
    white-space: unset;
  }

  /* Compose sticky + safe area bottom */
  .fs-compose{
    position: sticky;
    bottom: 0;
    z-index: 25;
    padding-bottom: calc(12px + var(--safe-bottom));
    background: rgba(255,255,255,.94);
    backdrop-filter: blur(10px);
  }

  .compose-input{
    background:#fff;
  }

  .compose-send{
    background: var(--userBubble);
    color:#fff;
    border-color: transparent;
  }
}

/* ===== Drawer (mobile suggestions) ===== */
.no-scroll{ overflow: hidden; }

.fs-drawer{
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
}

.fs-drawer-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.35);
  opacity: 0;
  transition: opacity .18s ease;
}

.fs-drawer-panel{
  position:absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: min(92vw, 420px);
  background: var(--card);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform .2s ease;
  display:flex;
  flex-direction: column;
}

.fs-drawer.is-open{
  pointer-events: auto;
}
.fs-drawer.is-open .fs-drawer-backdrop{
  opacity: 1;
}
.fs-drawer.is-open .fs-drawer-panel{
  transform: translateX(0);
}

.fs-drawer-header{
  padding: 12px 12px;
  padding-top: calc(12px + var(--safe-top));
  border-bottom: 1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}

.fs-drawer-body{
  padding: 12px;
  overflow:auto;
}

/* Chips: each group becomes horizontal scroll on mobile */
@media (max-width: 992px){
  .chips{ 
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 6px;
  }
  .chips::-webkit-scrollbar{ display:none; }

  .chip{
    white-space: nowrap;
    padding: 8px 12px;
    border-radius: 999px;
  }

  .chips-group{ gap: 12px; }
  .group-title{ margin-bottom: 6px; }
}
/* ===== Quick chips inside chat input (mobile) ===== */
.quick-chips{
  display: none;
}

@media (max-width: 768px){

  .quick-chips{
    display: grid;
    grid-auto-flow: column;          /* scroll ngang */
    grid-template-rows: repeat(2, auto); /* ✅ 2 hàng */
    gap: 8px;

    padding: 8px 4px 10px 4px;
    overflow-x: auto;
    overflow-y: hidden;

    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .quick-chips::-webkit-scrollbar{
    display: none;
  }

  .quick-chips .chip{
    white-space: nowrap;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.12);
    background: #fff;
    font-size: 13px;
    line-height: 1;
  }
}
.captcha-wrap{
  padding: 8px 4px 10px 4px;
}
.grecaptcha-badge {
  right: -100% !important;
}
/* ===== Intro Splash Screen ===== */
.intro-screen{
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;                 /* default hidden, JS will show */
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(245,246,248,.92);
  backdrop-filter: blur(10px);
}

.intro-screen.is-open{ display: flex; }

.intro-card{
  width: min(520px, 92vw);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 18px 48px rgba(0,0,0,.12);
}

.intro-logo{
  width: 92px;
  height: 92px;
  margin: 6px auto 12px;
  border-radius: 18px;
  display: grid;
  place-items: center;
}

.intro-logo img{
  width: 92px;
  height: 92px;
  object-fit: contain;
}

.intro-title{
  font-weight: 900;
  font-size: 20px;
  margin: 4px 0 2px;
}

.intro-sub{
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
  margin-bottom: 12px;
}

.intro-desc{
  font-size: 14px;
  line-height: 1.55;
  color: #374151;
  margin: 0 auto 14px;
  max-width: 44ch;
}

.intro-btn{
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 999px;
  background: #1A4173;
  color: #fff;
  font-weight: 800;
  letter-spacing: .2px;
}

.intro-btn:hover{ filter: brightness(1.05); }

.intro-note{
  margin-top: 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}
@media (max-width: 992px){
  .fs-topbar.is-hidden{
    display: none;
  }
}