/* =========================================================
   Drake — refined ChatGPT-style shell (dark glass)
   ========================================================= */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
.auth-honeypot{
  position:fixed!important;
  left:-10000px!important;
  top:auto!important;
  width:1px!important;
  height:1px!important;
  overflow:hidden!important;
  opacity:0!important;
  pointer-events:none!important;
}
:root{
  --bg:#070a10;
  --bg-elev:#0c111a;
  --side:#0a0e16;
  --side-hover:rgba(255,255,255,.055);
  --border:rgba(140,180,230,.1);
  --border-strong:rgba(160,200,255,.18);
  --text:#f2f7ff;
  --text-dim:rgba(220,235,255,.72);
  --text-muted:rgba(170,195,225,.48);
  --accent:#6aa8ff;
  --accent-2:#3de0ff;
  --user-bg:linear-gradient(145deg, rgba(80,140,255,.28), rgba(40,100,220,.16));
  --danger:#ff9a9a;
  --ok:#5cf0c8;
  --radius:20px;
  --font:'Plus Jakarta Sans',Inter,system-ui,sans-serif;
  --shadow-soft:0 8px 32px rgba(0,0,0,.35);
}
/* Khóa viewport: không phóng to/thu nhỏ, không cuộn cả trang */
html{
  height:100%;
  height:100dvh;
  overflow:hidden;
  overscroll-behavior:none;
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}
html,body{
  width:100%;
  max-width:100%;
  position:fixed;
  inset:0;
  overflow:hidden;
  touch-action:manipulation;
}
body.drake-body{
  font-family:var(--font);
  background:var(--bg);
  color:var(--text);
  height:100%;
  min-height:0;
  overflow:hidden;
  overscroll-behavior:none;
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
  /* đảm bảo body không chặn click xuống app */
  pointer-events:auto;
}
.drake-app{
  display:flex;
  height:100%;
  height:100dvh;
  max-height:100dvh;
  width:100%;
  max-width:100%;
  overflow:hidden;
  overscroll-behavior:none;
  position:relative;
  z-index:1;
  pointer-events:auto;
  background:
    radial-gradient(ellipse 90% 70% at 0% -20%, rgba(50,110,255,.22), transparent 55%),
    radial-gradient(ellipse 70% 55% at 100% 110%, rgba(0,200,255,.1), transparent 50%),
    var(--bg);
}
/* backdrop mặc định ẩn — tránh che click trên desktop */
.drake-side-backdrop{
  display:none !important;
  pointer-events:none !important;
}
button,a,.drake-icon-btn,.drake-send,.drake-new-btn,.drake-mode-btn,.drake-sug,.drake-conv-item{
  cursor:pointer;
  pointer-events:auto;
  position:relative;
  z-index:2;
}
#input,textarea,input{
  pointer-events:auto;
  position:relative;
  z-index:2;
}

/* ===== Sidebar ===== */
.drake-side{
  width:272px;flex-shrink:0;
  display:flex;flex-direction:column;
  background:linear-gradient(180deg, rgba(12,16,24,.95), rgba(8,11,18,.98));
  border-right:1px solid var(--border);
}
.drake-side-top{padding:1rem .85rem .55rem;display:flex;flex-direction:column;gap:.55rem}
.drake-new-btn{
  display:flex;align-items:center;justify-content:center;gap:.5rem;
  width:100%;min-height:46px;padding:.7rem 1rem;
  border:none;border-radius:14px;cursor:pointer;font:inherit;font-weight:700;
  color:#fff;
  background:linear-gradient(145deg, #4d8fff 0%, #2b6ef0 55%, #1a9fd4 100%);
  box-shadow:0 8px 24px rgba(40,110,255,.35), inset 0 1px 0 rgba(255,255,255,.25);
  transition:filter .15s, transform .12s;
}
.drake-new-btn:hover{filter:brightness(1.06)}
.drake-new-btn:active{transform:scale(.98)}
.drake-conv-list{
  flex:1;overflow-y:auto;padding:.25rem .65rem 1rem;
  display:flex;flex-direction:column;gap:.2rem;
  scrollbar-width:thin;scrollbar-color:rgba(120,160,220,.25) transparent;
}
.drake-conv-item{
  display:flex;align-items:center;gap:.55rem;
  width:100%;text-align:left;border:none;font:inherit;
  padding:0 .3rem 0 0;border-radius:12px;color:var(--text-dim);font-size:.88rem;font-weight:560;
  background:transparent;transition:background .15s,color .15s,box-shadow .15s;
}
.drake-conv-item:hover{background:var(--side-hover);color:var(--text)}
.drake-conv-item.active{
  background:rgba(90,150,255,.14);color:var(--text);
  box-shadow:inset 0 0 0 1px rgba(140,190,255,.2);
}
.drake-conv-open{
  display:flex;align-items:center;gap:.55rem;flex:1;min-width:0;
  padding:.72rem .5rem .72rem .8rem;border:none;background:transparent;color:inherit;
  text-align:left;font:inherit;font-weight:inherit;cursor:pointer;
}
.drake-conv-open i{opacity:.45;font-size:.8rem;flex-shrink:0}
.drake-conv-item span{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.drake-conv-del{
  opacity:0;border:none;background:transparent;color:var(--text-muted);
  cursor:pointer;padding:.25rem;border-radius:8px;font-size:.72rem;line-height:1;
}
.drake-conv-item:hover .drake-conv-del,
.drake-conv-item:focus-within .drake-conv-del{opacity:1}
.drake-conv-del:hover{color:var(--danger);background:rgba(255,100,100,.12)}
.drake-side-foot{
  padding:.85rem;border-top:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;gap:.5rem;
  background:rgba(0,0,0,.15);
}
.drake-user-chip{
  display:flex;align-items:center;gap:.55rem;min-width:0;
  font-size:.86rem;font-weight:650;color:var(--text-dim);
}
.drake-user-chip i{
  width:34px;height:34px;border-radius:11px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;
  background:linear-gradient(145deg, rgba(90,160,255,.45), rgba(40,200,255,.2));
  color:#fff;font-size:.85rem;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.2);
}
.drake-user-chip em{font-style:normal;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.drake-logout{
  border:none;background:rgba(255,255,255,.04);color:var(--text-muted);
  width:36px;height:36px;border-radius:11px;cursor:pointer;
  box-shadow:inset 0 0 0 1px var(--border);
  transition:color .15s,background .15s;
}
.drake-logout:hover{color:var(--text);background:rgba(255,255,255,.08)}
.drake-password-dialog{
  width:min(92vw,440px);
  padding:0;
  color:var(--text);
  border:1px solid var(--border-strong);
  border-radius:22px;
  background:rgba(9,16,29,.96);
  box-shadow:0 28px 90px rgba(0,0,0,.6);
}
.drake-password-dialog::backdrop{
  background:rgba(1,5,12,.72);
  backdrop-filter:blur(8px);
}
.drake-password-dialog form{display:grid;gap:.7rem;padding:1.25rem}
.drake-password-dialog label{font-size:.78rem;color:var(--text-dim);font-weight:700}
.drake-password-dialog input{
  width:100%;padding:.82rem .9rem;color:var(--text);
  border:1px solid var(--border-strong);border-radius:12px;
  outline:0;background:rgba(3,9,18,.72);
}
.drake-password-dialog input:focus{
  border-color:var(--accent);box-shadow:0 0 0 3px rgba(106,168,255,.15)
}
.password-dialog-head{display:flex;align-items:flex-start;justify-content:space-between;gap:1rem;margin-bottom:.2rem}
.password-dialog-head strong{display:block;font-size:1.05rem}
.password-dialog-head small{display:block;margin-top:.2rem;color:var(--text-muted)}
.drake-password-message{min-height:1.2rem;color:var(--danger);font-size:.78rem}
.drake-password-message.is-success{color:var(--ok)}

/* ===== Main ===== */
.drake-main{
  flex:1;
  min-width:0;
  min-height:0; /* quan trọng: cho phép messages scroll bên trong */
  height:100%;
  display:flex;
  flex-direction:column;
  position:relative;
  overflow:hidden;
}
.drake-main-top{
  flex-shrink:0;
  display:flex;align-items:center;justify-content:space-between;
  padding:.7rem 1.35rem;
  border-bottom:1px solid var(--border);
  background:rgba(8,12,18,.45);
  backdrop-filter:blur(16px);
  z-index:5;
}
.drake-brand{display:flex;align-items:center;gap:.65rem;font-weight:780;letter-spacing:-.02em}
.drake-brand-icon{
  width:38px;height:38px;border-radius:13px;
  display:flex;align-items:center;justify-content:center;color:#fff;
  background:linear-gradient(145deg, #5b9dff, #2ec8ff);
  box-shadow:0 8px 22px rgba(50,130,255,.4), inset 0 1px 0 rgba(255,255,255,.35);
}
.drake-brand > div > div:first-child{font-size:1.02rem}
.drake-status{font-size:.72rem;font-weight:650;color:var(--text-muted);margin-top:.08rem}
.drake-status.ok{color:var(--ok)}
.drake-menu-btn{
  display:none;border:none;background:rgba(255,255,255,.05);
  width:40px;height:40px;border-radius:12px;color:var(--text);cursor:pointer;
  box-shadow:inset 0 0 0 1px var(--border);
}
.drake-top-right{display:flex;align-items:center;gap:.7rem}
.drake-tools-link{
  display:inline-flex;align-items:center;gap:.35rem;
  color:var(--text-muted);font-size:.8rem;font-weight:650;text-decoration:none;
  padding:.4rem .7rem;border-radius:999px;
  box-shadow:inset 0 0 0 1px transparent;
  transition:color .15s, background .15s;
}
.drake-tools-link:hover{color:var(--text);background:rgba(255,255,255,.05)}

/* Mode selector — nằm trên thanh chat (composer) */
.drake-mode-wrap{position:relative;flex-shrink:1;min-width:0}
.drake-mode-btn{
  display:inline-flex;align-items:center;gap:.35rem;
  min-height:34px;max-width:100%;padding:.32rem .75rem;border:none;border-radius:999px;
  cursor:pointer;font:inherit;font-size:.78rem;font-weight:720;color:var(--text);
  background:rgba(255,255,255,.05);
  box-shadow:inset 0 0 0 1px var(--border-strong);
  transition:background .15s, box-shadow .15s;
  -webkit-tap-highlight-color:transparent;
}
.drake-mode-btn:hover{
  background:rgba(90,150,255,.12);
  box-shadow:inset 0 0 0 1px rgba(160,200,255,.35);
}
.drake-mode-btn i:first-child{color:#9ed0ff;font-size:.85rem;flex-shrink:0}
.drake-mode-btn span{
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:160px;
}
.drake-mode-menu{
  position:absolute;left:0;bottom:calc(100% + 10px);z-index:60;
  width:min(300px,calc(100vw - 2rem));padding:.45rem;
  border-radius:18px;
  background:rgba(12,18,28,.97);
  box-shadow:inset 0 0 0 1px rgba(180,210,255,.18), 0 -12px 40px rgba(0,0,0,.5);
  backdrop-filter:blur(24px);
  animation:popUp .16s ease;
}
@keyframes popUp{from{opacity:0;transform:translateY(6px) scale(.98)}to{opacity:1;transform:none}}
.drake-mode-item{
  display:flex;align-items:flex-start;gap:.65rem;width:100%;
  text-align:left;border:none;cursor:pointer;font:inherit;
  padding:.72rem .8rem;border-radius:13px;color:var(--text);
  background:transparent;transition:background .12s;
}
.drake-mode-item:hover{background:rgba(255,255,255,.06)}
.drake-mode-item.active{background:rgba(90,150,255,.15)}
.drake-mode-item > i:first-child{
  width:22px;margin-top:.12rem;text-align:center;color:#9ed0ff;font-size:.95rem;flex-shrink:0;
}
.drake-mode-meta{flex:1;min-width:0;display:flex;flex-direction:column;gap:.1rem}
.drake-mode-meta strong{font-size:.9rem;font-weight:750}
.drake-mode-meta em{font-style:normal;font-size:.72rem;color:var(--text-muted);font-weight:550}
.drake-mode-item .mode-check{opacity:0;color:var(--ok);font-size:.72rem;margin-top:.18rem}
.drake-mode-item.active .mode-check{opacity:1}

/* Messages */
.drake-messages{
  flex:1 1 auto;
  min-height:0; /* bắt buộc trong flex column — chỉ vùng này cuộn */
  overflow-x:hidden;
  overflow-y:auto;
  padding:1.5rem 1.25rem 1.5rem;
  scroll-behavior:smooth;
  -webkit-overflow-scrolling:touch;
  overscroll-behavior:contain; /* không kéo cả trang */
  touch-action:pan-y;
  scrollbar-width:thin;scrollbar-color:rgba(120,160,220,.2) transparent;
}
.drake-messages-inner{max-width:800px;margin:0 auto;width:100%}

.drake-empty{
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  text-align:center;min-height:min(62dvh,540px);padding:2rem 1rem;
}
.drake-empty-icon{
  width:76px;height:76px;border-radius:24px;margin-bottom:1.15rem;
  display:flex;align-items:center;justify-content:center;font-size:1.7rem;color:#fff;
  background:linear-gradient(145deg, #5b9dff, #2ec8ff);
  box-shadow:0 18px 48px rgba(40,120,255,.38), inset 0 1px 0 rgba(255,255,255,.4);
}
.drake-empty h1{
  font-size:clamp(1.4rem,3vw,1.75rem);font-weight:820;letter-spacing:-.035em;margin-bottom:.4rem;
  background:linear-gradient(120deg,#fff 15%,#a8d0ff 90%);
  -webkit-background-clip:text;background-clip:text;color:transparent;
}
.drake-empty p{color:var(--text-dim);max-width:400px;margin-bottom:1.5rem;font-size:.95rem;line-height:1.55}
.drake-sugs{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.55rem;max-width:520px;width:100%}
.drake-sug{
  border:none;cursor:pointer;font:inherit;font-size:.82rem;font-weight:600;
  color:var(--text-dim);padding:.85rem 1rem;border-radius:16px;text-align:left;
  background:rgba(255,255,255,.035);
  box-shadow:inset 0 0 0 1px var(--border);
  transition:background .15s,color .15s,transform .12s,box-shadow .15s;
}
.drake-sug:hover{
  background:rgba(90,150,255,.12);color:var(--text);
  transform:translateY(-1px);
  box-shadow:inset 0 0 0 1px rgba(160,200,255,.28);
}

.drake-msg{
  display:flex;gap:.8rem;margin-bottom:1.45rem;
  animation:fadeIn .28s ease;
}
@keyframes fadeIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}
.drake-msg.user{flex-direction:row-reverse}
.drake-avatar{
  width:34px;height:34px;border-radius:12px;flex-shrink:0;
  display:flex;align-items:center;justify-content:center;font-size:.85rem;
  box-shadow:inset 0 1px 0 rgba(255,255,255,.15);
}
.drake-avatar.bot{
  background:linear-gradient(145deg, #5b9dff, #2ec8ff);color:#fff;
}
.drake-avatar.user{background:rgba(255,255,255,.1);color:var(--text)}
.drake-bubble{min-width:0;max-width:min(100%,760px)}
.drake-msg.user .drake-bubble{text-align:right;max-width:min(100%,560px)}
.drake-role{
  font-size:.62rem;font-weight:720;letter-spacing:.06em;text-transform:uppercase;
  color:var(--text-muted);margin-bottom:.32rem;
}
.drake-text{
  font-size:.975rem;line-height:1.72;color:var(--text);
  word-wrap:break-word;overflow-wrap:anywhere;
  letter-spacing:.005em;
}
.drake-msg.user .drake-text{
  display:inline-block;text-align:left;
  padding:.8rem 1.05rem;border-radius:20px 20px 6px 20px;
  background:var(--user-bg);
  box-shadow:inset 0 0 0 1px rgba(160,200,255,.22), 0 6px 20px rgba(20,60,140,.15);
}
.drake-text p{margin:0 0 .85em}
.drake-text p:last-child{margin-bottom:0}
.drake-text > :first-child{margin-top:0}
.drake-text > :last-child{margin-bottom:0}

/* ----- Markdown structure (Grok-like) ----- */
.drake-md-h{
  font-weight:750;line-height:1.3;color:#f5f9ff;
  margin:1.15em 0 .55em;letter-spacing:-.01em;
}
.drake-text h1.drake-md-h{font-size:1.35rem}
.drake-text h2.drake-md-h{font-size:1.18rem}
.drake-text h3.drake-md-h{font-size:1.06rem}
.drake-text h4.drake-md-h{font-size:1rem;color:var(--text-dim)}
.drake-text > .drake-md-h:first-child{margin-top:0}
.drake-md-list{
  margin:.35em 0 1em;padding-left:1.35rem;
  display:flex;flex-direction:column;gap:.4rem;
}
.drake-md-list li{
  margin:0;padding-left:.15rem;
  color:var(--text);
}
.drake-md-list li::marker{color:var(--accent);font-weight:700}
.drake-text ol.drake-md-list{list-style:decimal}
.drake-text ul.drake-md-list{list-style:disc}
.drake-md-list li > ul,.drake-md-list li > ol{margin:.35em 0 .15em}
.drake-md-quote{
  margin:.75em 0;padding:.55rem .9rem .55rem 1rem;
  border-left:3px solid rgba(100,170,255,.55);
  background:rgba(100,150,255,.07);
  border-radius:0 12px 12px 0;
  color:var(--text-dim);
}
.drake-md-quote p{margin:0 0 .4em}
.drake-md-quote p:last-child{margin:0}
.drake-md-hr{
  border:none;height:1px;margin:1.1em 0;
  background:linear-gradient(90deg, transparent, rgba(160,200,255,.28), transparent);
}
.drake-md-link{
  color:#8ec5ff;text-decoration:none;font-weight:600;
  border-bottom:1px solid rgba(142,197,255,.35);
  transition:color .12s,border-color .12s;
}
.drake-md-link:hover{color:#c4e0ff;border-bottom-color:rgba(196,224,255,.7)}
.drake-text strong{font-weight:720;color:#fff}
.drake-text em{font-style:italic;color:var(--text-dim)}
.drake-text del{opacity:.65}

/* ----- Code blocks ----- */
.drake-code{
  margin:.85rem 0 1.05rem;
  border-radius:14px;overflow:hidden;
  background:linear-gradient(180deg, rgba(14,18,28,.95), rgba(8,11,18,.98));
  box-shadow:
    inset 0 0 0 1px rgba(150,190,240,.14),
    0 10px 28px rgba(0,0,0,.28);
}
.drake-code-bar{
  display:flex;align-items:center;justify-content:space-between;gap:.5rem;
  padding:.45rem .75rem;
  background:rgba(255,255,255,.035);
  border-bottom:1px solid rgba(140,180,230,.1);
}
.drake-code-lang{
  font-size:.72rem;font-weight:700;letter-spacing:.04em;text-transform:uppercase;
  color:var(--text-muted);
}
.drake-code-copy{
  display:inline-flex;align-items:center;gap:.35rem;
  border:none;cursor:pointer;font:inherit;
  font-size:.72rem;font-weight:650;
  color:var(--text-dim);
  background:rgba(255,255,255,.06);
  padding:.28rem .55rem;border-radius:8px;
  transition:background .12s,color .12s;
}
.drake-code-copy:hover{background:rgba(255,255,255,.1);color:var(--text)}
.drake-code-copy.copied{color:var(--ok)}
.drake-code pre{
  margin:0;padding:.9rem 1rem 1rem;overflow-x:auto;
  font-family:ui-monospace,"Cascadia Code",Menlo,Consolas,monospace;
  font-size:.84rem;line-height:1.55;color:#e4eefc;
  tab-size:4;
  scrollbar-width:thin;scrollbar-color:rgba(120,160,220,.3) transparent;
}
.drake-code code{
  font-family:inherit;font-size:inherit;
  padding:0;background:none;color:inherit;
  white-space:pre;
}
.drake-inline-code,
.drake-text code{
  font-family:ui-monospace,Menlo,Consolas,monospace;font-size:.88em;
  padding:.12rem .42rem;border-radius:7px;
  background:rgba(120,170,255,.12);color:#c8e4ff;
  box-shadow:inset 0 0 0 1px rgba(140,190,255,.12);
  white-space:break-spaces;
}
.drake-code .tok-kw{color:#ff7ab8;font-weight:600}
.drake-code .tok-str{color:#9dffa8}
.drake-code .tok-cmt{color:#6b7f99;font-style:italic}
.drake-code .tok-num{color:#ffd28a}
.drake-code .tok-fn{color:#7ecbff}
/* legacy bare pre (fallback) */
.drake-text > pre{
  margin:.6rem 0;padding:.9rem 1rem;border-radius:14px;overflow-x:auto;
  background:rgba(0,0,0,.42);font-family:ui-monospace,Menlo,Consolas,monospace;
  font-size:.82rem;line-height:1.5;color:#d6ecff;
  box-shadow:inset 0 0 0 1px rgba(140,180,230,.12);
}
.drake-text > pre code{padding:0;background:none;box-shadow:none}
.drake-file-chip{
  display:inline-flex;align-items:center;gap:.45rem;
  margin-top:.45rem;padding:.4rem .7rem;border-radius:10px;
  font-size:.78rem;font-weight:650;color:var(--text-dim);
  background:rgba(255,255,255,.06);
  box-shadow:inset 0 0 0 1px var(--border);
}
.drake-file-chip i{color:#9ed0ff}
.drake-media-fig{
  margin:.75rem 0;padding:0;max-width:min(100%,420px);
}
.drake-media-img{
  display:block;width:100%;max-height:min(60vh,480px);object-fit:contain;
  border-radius:16px;background:rgba(0,0,0,.25);
  box-shadow:inset 0 0 0 1px rgba(160,200,255,.15), 0 8px 28px rgba(0,0,0,.3);
}
.drake-media-fig figcaption{
  margin-top:.4rem;font-size:.75rem;color:var(--text-muted);font-weight:600;
}
.drake-media-fig figcaption a,.drake-media-link,.drake-media-file a{
  color:#9ed0ff;text-decoration:none;font-weight:650;
}
.drake-media-fig figcaption a:hover,.drake-media-link:hover,.drake-media-file a:hover{
  text-decoration:underline;
}
.drake-media-file{
  margin:.65rem 0;display:flex;flex-direction:column;gap:.4rem;max-width:min(100%,420px);
}
.drake-media-video{
  width:100%;max-height:min(50vh,360px);border-radius:14px;background:#000;
}
.drake-media-audio{width:100%}
.drake-media-link{
  display:inline-flex;align-items:center;gap:.4rem;
  padding:.45rem .75rem;border-radius:10px;
  background:rgba(90,150,255,.1);box-shadow:inset 0 0 0 1px rgba(140,190,255,.2);
}
.drake-cursor{
  display:inline-block;width:7px;height:1em;margin-left:2px;vertical-align:text-bottom;
  background:var(--accent);border-radius:2px;animation:blink .9s step-end infinite;
}
@keyframes blink{50%{opacity:0}}
.drake-msg.error .drake-text{color:var(--danger)}

/* Composer */
.drake-composer-wrap{
  flex-shrink:0;
  padding:.35rem 1.25rem 1.1rem;
  background:linear-gradient(0deg, rgba(5,8,14,.95) 30%, transparent);
}
.drake-composer{
  max-width:800px;margin:0 auto;
  border-radius:24px;padding:.55rem .7rem .5rem;
  background:rgba(255,255,255,.045);
  box-shadow:
    inset 0 0 0 1px rgba(170,210,255,.18),
    0 14px 40px rgba(0,0,0,.32);
  backdrop-filter:blur(22px);
  transition:box-shadow .2s;
}
.drake-composer:focus-within{
  box-shadow:
    inset 0 0 0 1px rgba(120,180,255,.4),
    0 14px 40px rgba(30,90,200,.18);
}
.drake-attach-preview{
  display:none;align-items:center;gap:.5rem;flex-wrap:wrap;
  padding:.35rem .4rem .15rem;
}
.drake-attach-preview.show{display:flex}
.drake-attach-item{
  display:inline-flex;align-items:center;gap:.4rem;
  padding:.35rem .65rem;border-radius:10px;font-size:.78rem;font-weight:650;
  color:var(--text-dim);background:rgba(90,150,255,.12);
  box-shadow:inset 0 0 0 1px rgba(140,190,255,.2);
  max-width:100%;
}
.drake-attach-item span{
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:200px;
}
.drake-attach-item button{
  border:none;background:transparent;color:var(--text-muted);cursor:pointer;
  padding:0 .15rem;font-size:.85rem;line-height:1;
}
.drake-attach-item button:hover{color:var(--danger)}
.drake-composer textarea{
  width:100%;border:none;outline:none;resize:none;background:transparent;
  color:var(--text);font:inherit;font-size:1rem;line-height:1.5;
  min-height:28px;max-height:160px;padding:.35rem .45rem .2rem;
}
.drake-composer textarea::placeholder{color:var(--text-muted)}
.drake-composer-bar{
  display:flex;align-items:center;justify-content:space-between;gap:.5rem;
  margin-top:.2rem;padding:0 .15rem;
}
.drake-composer-left{
  display:flex;align-items:center;gap:.35rem;
  flex:1;min-width:0;
}
.drake-icon-btn{
  width:38px;height:38px;border-radius:12px;border:none;cursor:pointer;
  display:inline-flex;align-items:center;justify-content:center;
  color:var(--text-dim);background:transparent;font-size:1rem;
  transition:background .15s,color .15s;
}
.drake-icon-btn:hover{background:rgba(255,255,255,.07);color:var(--text)}
.drake-icon-btn.has-file{color:#9ed0ff;background:rgba(90,150,255,.12)}
.drake-composer-hint{font-size:.68rem;color:var(--text-muted);font-weight:600}
.drake-send{
  width:40px;height:40px;border-radius:14px;border:none;cursor:pointer;color:#fff;
  background:linear-gradient(145deg, #5b9dff, #2a7fff 50%, #1ec8ff);
  box-shadow:0 8px 22px rgba(40,120,255,.42), inset 0 1px 0 rgba(255,255,255,.3);
  display:inline-flex;align-items:center;justify-content:center;
  transition:filter .15s, transform .12s;
}
.drake-send:hover{filter:brightness(1.06)}
.drake-send:active{transform:scale(.96)}
.drake-send:disabled{opacity:.4;cursor:not-allowed;filter:none;transform:none}
.drake-disclaimer{
  text-align:center;font-size:.68rem;color:var(--text-muted);margin-top:.5rem;font-weight:500;
}

/* Auth */
.drake-auth-overlay{
  position:fixed;inset:0;z-index:100;
  display:flex;align-items:center;justify-content:center;padding:1.25rem;
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(60,120,255,.32), transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(0,200,255,.12), transparent 50%),
    rgba(5,8,14,.94);
  backdrop-filter:blur(18px);
}
.drake-auth-card{
  width:100%;max-width:400px;padding:1.85rem 1.55rem 1.55rem;
  border-radius:26px;
  background:linear-gradient(165deg, rgba(255,255,255,.1), rgba(255,255,255,.03));
  box-shadow:inset 0 0 0 1px rgba(180,210,255,.2), 0 28px 70px rgba(0,0,0,.5);
}
.drake-auth-card h1{font-size:1.5rem;font-weight:820;text-align:center;margin:.55rem 0 .35rem;letter-spacing:-.03em}
.drake-auth-card .sub{text-align:center;color:var(--text-dim);font-size:.9rem;margin-bottom:1.25rem}
.drake-auth-policy{
  display:flex;align-items:flex-start;gap:.6rem;
  margin:-.35rem 0 1rem;padding:.72rem .8rem;border-radius:13px;
  color:#b9cce4;background:rgba(75,125,195,.09);
  box-shadow:inset 0 0 0 1px rgba(130,185,255,.15);
  font-size:.72rem;line-height:1.45;
}
.drake-auth-policy i{color:#8fc8ff;margin-top:.13rem;flex-shrink:0}
.drake-auth-policy.policy-pending{
  color:#ecd7aa;background:rgba(185,128,39,.09);
  box-shadow:inset 0 0 0 1px rgba(244,190,97,.17);
}
.drake-auth-policy.policy-pending i{color:#f2c576}
.drake-auth-policy.policy-open{
  color:#afe5d2;background:rgba(43,151,116,.09);
  box-shadow:inset 0 0 0 1px rgba(83,214,172,.17);
}
.drake-auth-policy.policy-open i{color:#63d9b4}
.drake-auth-tabs{display:flex;gap:.4rem;margin-bottom:1rem}
.drake-auth-tabs button{
  flex:1;border:none;cursor:pointer;font:inherit;font-weight:720;font-size:.9rem;
  padding:.68rem;border-radius:13px;color:var(--text-dim);background:rgba(255,255,255,.04);
}
.drake-auth-tabs button.active{
  color:#fff;
  background:linear-gradient(145deg, rgba(90,160,255,.42), rgba(40,180,255,.2));
  box-shadow:inset 0 0 0 1px rgba(180,220,255,.28);
}
.drake-auth-tabs button:disabled{
  cursor:not-allowed;opacity:.42;color:var(--text-muted);
  background:rgba(255,255,255,.025);box-shadow:none;
}
.drake-auth-card label{
  display:block;font-size:.72rem;font-weight:720;color:var(--text-muted);
  margin:.7rem 0 .3rem;text-transform:uppercase;letter-spacing:.04em;
}
.drake-auth-card input{
  width:100%;min-height:48px;padding:.65rem .95rem;border:none;border-radius:13px;
  font:inherit;color:var(--text);background:rgba(0,0,0,.35);
  box-shadow:inset 0 0 0 1px var(--border);
}
.drake-auth-card input:focus{outline:none;box-shadow:inset 0 0 0 1px rgba(100,170,255,.5)}
.drake-auth-submit{
  width:100%;margin-top:1.2rem;min-height:50px;border:none;border-radius:15px;
  cursor:pointer;font:inherit;font-weight:760;color:#fff;font-size:.96rem;
  background:linear-gradient(145deg, #5b9dff, #2a7fff);
  box-shadow:0 12px 30px rgba(40,120,255,.38);
}
.drake-auth-submit:disabled{opacity:.5;cursor:not-allowed}
.drake-auth-err{margin-top:.75rem;font-size:.85rem;color:var(--danger);text-align:center;min-height:1.2em}
.drake-auth-err.is-notice{color:#f0ca82}
.drake-auth-err.is-success{color:var(--ok)}
.drake-auth-logo{
  width:58px;height:58px;border-radius:18px;margin:0 auto;
  display:flex;align-items:center;justify-content:center;color:#fff;font-size:1.35rem;
  background:linear-gradient(145deg, #5b9dff, #2ec8ff);
  box-shadow:0 14px 36px rgba(40,120,255,.4);
}
.drake-access-state{
  display:flex;align-items:center;gap:.75rem;
  margin:.8rem 1.25rem 0;padding:.8rem .9rem;border-radius:15px;
  color:#e8d3a7;background:rgba(170,112,27,.1);
  box-shadow:inset 0 0 0 1px rgba(239,188,97,.18);
}
.drake-access-state>i{color:#f1c36f;font-size:1.05rem;flex-shrink:0}
.drake-access-state>span{display:flex;min-width:0;flex:1;flex-direction:column}
.drake-access-state strong{font-size:.78rem}
.drake-access-state small{color:#b9a98a;font-size:.66rem;line-height:1.4}
.drake-access-state a{
  flex-shrink:0;padding:.4rem .65rem;border-radius:999px;
  color:#cfe6ff;background:rgba(80,139,215,.12);
  box-shadow:inset 0 0 0 1px rgba(130,188,255,.16);
  font-size:.68rem;font-weight:700;text-decoration:none;
}
.drake-access-restricted .drake-composer{opacity:.68}
.drake-new-btn:disabled,.drake-icon-btn:disabled{
  cursor:not-allowed;opacity:.42;filter:none;transform:none;
}
.hidden{display:none!important}

@media(max-width:820px){
  /* Shell full màn — tỷ lệ cố định, không zoom */
  .drake-app{
    height:100dvh;
    max-height:100dvh;
    width:100vw;
    max-width:100vw;
  }
  .drake-main{
    min-height:0;
    overflow:hidden;
  }
  .drake-main-top{
    flex-shrink:0;
    padding:
      max(.5rem, env(safe-area-inset-top, 0px))
      .65rem
      .5rem
      .55rem;
    gap:.4rem;
  }
  .drake-side{
    position:fixed;left:0;top:0;bottom:0;z-index:50;
    width:min(86vw,300px);
    transform:translateX(-105%);
    transition:transform .28s cubic-bezier(.2,.8,.2,1);
    box-shadow:none;
  }
  .drake-side.open{transform:translateX(0);box-shadow:16px 0 48px rgba(0,0,0,.55)}
  .drake-menu-btn{
    display:inline-flex!important;
    align-items:center;justify-content:center;
    width:42px;height:42px;min-width:42px;
  }
  .drake-side-backdrop{
    display:none !important;
    position:fixed;inset:0;z-index:40;background:rgba(0,0,0,.5);
    pointer-events:none !important;
  }
  .drake-side-backdrop.open{
    display:block !important;
    pointer-events:auto !important;
  }

  .drake-messages{
    flex:1 1 0;
    min-height:0;
    padding:.85rem .7rem 1rem;
  }
  .drake-composer-wrap{
    flex-shrink:0;
    padding:
      .2rem
      .65rem
      max(.65rem, env(safe-area-inset-bottom, 0px));
  }
  .drake-composer textarea{
    font-size:16px; /* chặn iOS auto-zoom khi focus input */
  }
  .drake-auth-card input{
    font-size:16px;
  }
  .drake-auth-overlay{align-items:flex-start;overflow-y:auto;padding:max(1rem,env(safe-area-inset-top)) .8rem max(1rem,env(safe-area-inset-bottom))}
  .drake-auth-card{margin:auto 0;padding:1.35rem 1rem 1.15rem;border-radius:21px}
  .drake-auth-policy{font-size:.69rem}
  .drake-access-state{margin:.55rem .65rem 0;padding:.7rem}
  .drake-access-state a{display:none}
  .drake-composer-hint{display:none}
  .drake-sugs{grid-template-columns:1fr}
  .drake-mode-btn{
    min-height:36px;
    padding:.3rem .65rem;
    font-size:.74rem;
  }
  .drake-mode-btn span{max-width:min(42vw,140px)}
  .drake-mode-menu{
    left:0;
    right:auto;
    width:min(280px,calc(100vw - 1.5rem));
  }
  .drake-tools-link{font-size:.72rem;padding:.35rem .5rem}
  .drake-msg{margin-bottom:1.05rem}
  .drake-empty{min-height:min(52dvh,400px);padding:1.2rem .75rem}
}

:where(button,a,textarea,input,[tabindex]):focus-visible{
  outline:2px solid #8ec5ff;
  outline-offset:3px;
}

@media (hover:none), (pointer:coarse){
  .drake-conv-del{opacity:.72}
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{
    animation-duration:.01ms!important;
    animation-iteration-count:1!important;
    transition-duration:.01ms!important;
    scroll-behavior:auto!important;
  }
}
