/* TIEN404 AI live consultant — public QA pilot */
.ai-live{padding:70px 0 90px;position:relative}
.ai-live-head{display:flex;align-items:flex-start;justify-content:space-between;flex-wrap:wrap;gap:24px;margin-bottom:25px}
.ai-live-head h2{font-size:clamp(27px,4vw,42px);max-width:780px;line-height:1.15;letter-spacing:-.04em;margin:10px 0 14px}
.ai-live-head p{max-width:780px;color:#c1c6dc;font-size:15px;line-height:1.75}
.ai-live-status{display:inline-flex;align-items:center;gap:8px;border:1px solid #54c9a67a;color:#76f0be;background:#14392f56;padding:8px 13px;border-radius:30px;font-size:12px;font-weight:750;letter-spacing:.03em}
.ai-live-status:before{content:"";width:7px;height:7px;border-radius:50%;background:#65dbac;box-shadow:0 0 12px #65dbac}
.ai-live-notice{padding:14px 18px;margin:0 0 22px;border:1px solid #5b659873;background:#16192c;color:#cbd2e7;border-radius:14px;font-size:13px;line-height:1.7}
.ai-live-card{padding:14px;border:1px solid #6255af77;border-radius:24px;background:linear-gradient(150deg,#15172df0,#090a19);box-shadow:0 23px 95px #0005;overflow:hidden}
.tien404-ai-chat{height:590px;min-height:440px;overflow:hidden;border-radius:15px;background:#0c0d1e}
.tien404-ai-chat #n8n-chat,.tien404-ai-chat .chat-layout{height:100%}
#n8n-chat{--chat--color-primary:#8958f9;--chat--color-primary-shade-50:#6946db;--chat--color-primary-shade-100:#5639ae;--chat--color-secondary:#35b9e9;--chat--color-white:#f8f8ff;--chat--color-light:#1a1d32;--chat--color-dark:#e9eaf7;--chat--color-background:#0c0d1e;--chat--body--background:#0c0d1e;--chat--message--bot--background:#232640;--chat--message--bot--color:#eff0ff;--chat--message--user--background:#7553dc;--chat--message--user--color:#fff;--chat--header--background:#101226;--chat--header--color:#f8f8ff;--chat--window--width:100%;--chat--window--height:100%}
.ai-live-links{display:flex;gap:12px;flex-wrap:wrap;margin-top:21px}
.ai-live-links a{color:#b8c4ff;text-decoration:underline;text-underline-offset:4px;font-size:13px}
.ai-live-banner{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:15px;border:1px solid #765fe583;background:#1a16416b;padding:18px 20px;margin-top:22px;margin-bottom:40px;border-radius:16px}
.ai-live-banner strong{color:#dce2ff;font-size:14px}
.ai-live-banner a{font-weight:700;color:#9deaff;font-size:14px}
@media(max-width:600px){.ai-live{padding:45px 0 70px}.ai-live-card{padding:5px;border-radius:15px}.tien404-ai-chat{height:530px;min-height:400px;border-radius:11px}.ai-live-head p{font-size:14px}.ai-live-banner{margin:20px 0}}
@media(prefers-reduced-motion:reduce){.ai-live-status:before{box-shadow:none}}


/* Mobile conversation usability fix — 2026-11-10.
   Keep the composer visible and make message history the primary scroll area. */
#n8n-chat, #n8n-chat .chat-layout, #n8n-chat .chat-window {
  min-height:0;
  min-width:0;
}
#n8n-chat .chat-layout {
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
#n8n-chat .chat-header {
  flex:0 0 auto;
}
#n8n-chat .chat-body {
  flex:1 1 0%;
  min-height:0;
  overflow-y:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}
#n8n-chat .chat-footer {
  flex:0 0 auto;
  min-height:0;
}
#n8n-chat .chat-input,
#n8n-chat .chat-inputs,
#n8n-chat .chat-inputs textarea {
  min-width:0;
}
#n8n-chat .chat-inputs textarea {
  box-sizing:border-box;
  max-height:132px;
  overflow-y:auto;
  font-size:16px;
  line-height:1.45;
  resize:vertical;
}
@media(max-width:600px) {
  .ai-live-card { padding:4px; overflow:hidden; }
  .tien404-ai-chat {
    height: min(690px, calc(100dvh - 108px));
    min-height: min(460px, calc(100dvh - 108px));
  }
  #n8n-chat .chat-header {
    padding:10px 14px !important;
    min-height:0 !important;
    max-height:88px;
    overflow:hidden;
  }
  #n8n-chat .chat-header h1,
  #n8n-chat .chat-header .chat-heading h1 {
    font-size:17px !important;
    line-height:1.3 !important;
    margin:0 0 3px !important;
    letter-spacing:0 !important;
  }
  #n8n-chat .chat-header p,
  #n8n-chat .chat-header .chat-heading p {
    font-size:11px !important;
    line-height:1.35 !important;
    margin:0 !important;
  }
  #n8n-chat .chat-body { padding:10px 8px !important; }
  #n8n-chat .chat-message { max-width:94%; overflow-wrap:anywhere; }
  #n8n-chat .chat-footer { padding:5px 6px 8px !important; }
  #n8n-chat .chat-inputs textarea {
    min-height:48px;
    max-height:112px;
    padding:10px 12px;
  }
}
@media(max-width:600px) and (max-height:650px) {
  #n8n-chat .chat-header { max-height:70px; padding:6px 10px !important; }
  .tien404-ai-chat { height:calc(100dvh - 92px); min-height:300px; }
}


/* Android dark-mode / forced-dark text visibility fix.
   n8n chat inherits light/dark variables; explicitly pair background and foreground. */
#n8n-chat .chat-input,
#n8n-chat .chat-inputs,
#n8n-chat .chat-inputs textarea,
#n8n-chat .chat-inputs input,
#n8n-chat textarea,
#n8n-chat input[type="text"] {
  color-scheme:light !important;
  background-color:#ffffff !important;
  color:#172033 !important;
  -webkit-text-fill-color:#172033 !important;
  caret-color:#5138b5 !important;
  opacity:1 !important;
}
#n8n-chat .chat-inputs textarea::placeholder,
#n8n-chat .chat-inputs input::placeholder,
#n8n-chat textarea::placeholder,
#n8n-chat input[type="text"]::placeholder {
  color:#626b7e !important;
  -webkit-text-fill-color:#626b7e !important;
  opacity:1 !important;
}
#n8n-chat .chat-inputs textarea::selection,
#n8n-chat .chat-inputs input::selection {
  color:#172033;
  background:#cfc4ff;
}
#n8n-chat .chat-inputs textarea:focus,
#n8n-chat .chat-inputs input:focus {
  outline-color:#7856e8;
}


/* Composer foreground fix: override all n8n chat variables and input states. */
#n8n-chat {
  --chat--input--text-color:#172033;
  --chat--input--background:#ffffff;
  --chat--input--placeholder-color:#596477;
  --chat--textarea--color:#172033;
}
#n8n-chat .chat-footer textarea,
#n8n-chat .chat-footer input,
#n8n-chat .chat-inputs textarea,
#n8n-chat .chat-inputs input,
#n8n-chat .chat-footer [contenteditable="true"],
#n8n-chat .chat-footer textarea:focus,
#n8n-chat .chat-footer input:focus,
#n8n-chat .chat-footer [contenteditable="true"]:focus {
  color:#172033 !important;
  -webkit-text-fill-color:#172033 !important;
  background:#ffffff !important;
  caret-color:#5c3ac7 !important;
  color-scheme:light !important;
  text-shadow:none !important;
  opacity:1 !important;
}
#n8n-chat .chat-footer textarea::placeholder,
#n8n-chat .chat-footer input::placeholder {
  color:#596477 !important;
  -webkit-text-fill-color:#596477 !important;
  opacity:1 !important;
}


/* Independent TIEN404 composer: bypasses Android forced-dark n8n textarea rendering. */
.ai-live-card{display:flex;flex-direction:column;min-width:0}
.tien404-ai-chat{flex:1 1 auto;min-height:0}
#n8n-chat.tien404-custom-compose .chat-footer{display:none!important}
.tien404-composer[hidden]{display:none!important}
.tien404-composer{
  flex:0 0 auto;
  padding:10px 12px 12px;
  background:#14172c;
  border-top:1px solid #46405f;
  color-scheme:light;
}
.tien404-composer-label{display:block;color:#dfe3ff;font-size:12px;font-weight:600;margin-bottom:7px}
.tien404-composer-row{display:flex;gap:8px;align-items:flex-end}
#tien404-message{
  display:block!important;
  box-sizing:border-box!important;
  flex:1 1 auto;
  min-width:0;
  width:100%;
  min-height:60px;
  max-height:160px;
  padding:12px!important;
  border:2px solid #8c7cda!important;
  border-radius:12px!important;
  background:#fff!important;
  background-image:none!important;
  color:#101827!important;
  -webkit-text-fill-color:#101827!important;
  caret-color:#4425b0!important;
  color-scheme:light!important;
  font:normal 16px/1.5 system-ui,-apple-system,sans-serif!important;
  letter-spacing:normal!important;
  text-shadow:none!important;
  opacity:1!important;
  resize:vertical;
  overflow:auto;
}
#tien404-message::placeholder{color:#657083!important;-webkit-text-fill-color:#657083!important;opacity:1!important}
#tien404-message:focus{outline:2px solid #b9a7ff!important;outline-offset:1px}
#tien404-send{
  flex:0 0 auto;
  min-height:48px;
  border:0;
  border-radius:12px;
  background:#7653e8;
  color:#fff;
  padding:0 17px;
  font:700 15px system-ui,sans-serif;
  cursor:pointer;
}
#tien404-send:disabled{opacity:.55;cursor:wait}
.tien404-composer-status{margin:5px 0 0;color:#ffd6d6;font-size:12px}
.tien404-composer-status:empty{display:none}
@media(max-width:600px){
 .tien404-ai-chat{height:min(570px,calc(100dvh - 220px));min-height:280px}
 .tien404-composer{padding:8px}
 #tien404-message{min-height:54px;max-height:120px}
}


/* Mobile-first compact embedded chat. Outer page remains scrollable. */
.tien404-chat-toolbar{display:none}
@media(max-width:600px){
 .ai-live-card{padding:4px!important;overflow:visible!important}
 .tien404-chat-toolbar{
   display:flex;align-items:center;justify-content:space-between;gap:10px;
   padding:8px 10px;background:#17182d;color:#e9e8ff;
   font:600 13px/1.3 system-ui,sans-serif;border-radius:11px 11px 0 0;
 }
 #tien404-chat-expand{
   border:1px solid #8070c4;border-radius:8px;background:#302b55;
   color:#fff;padding:8px 10px;font:600 12px system-ui,sans-serif;
   white-space:nowrap;min-height:36px;
 }
 .tien404-ai-chat{
   height:300px!important;min-height:0!important;max-height:none!important;
   flex:0 0 auto!important;overflow:hidden!important;
 }
 .tien404-chat-expanded .tien404-ai-chat{height:min(60dvh,520px)!important}
 #n8n-chat .chat-header{
   padding:7px 10px!important;max-height:62px!important;
   min-height:0!important;
 }
 #n8n-chat .chat-header h1{font-size:15px!important;line-height:1.2!important}
 #n8n-chat .chat-header p{font-size:10px!important;line-height:1.2!important}
 #n8n-chat .chat-body{
   min-height:0!important;overflow-y:auto!important;
   overscroll-behavior-y:auto!important;
   touch-action:pan-y!important;
   -webkit-overflow-scrolling:touch;
   padding:8px!important;
 }
 #n8n-chat .chat-message{font-size:13px!important;line-height:1.45!important}
 #n8n-chat .chat-message-markdown{font-size:13px!important;line-height:1.45!important}
 .tien404-composer{padding:6px 8px 8px!important}
 .tien404-composer-label{font-size:11px;margin-bottom:4px}
 #tien404-message{min-height:44px!important;max-height:100px!important;padding:9px!important}
 #tien404-send{min-height:44px!important;padding:0 13px}
}


/* V7 floating chat: compact launcher and collapsible fixed panel. */
.tien404-floating-widget{position:fixed;right:18px;bottom:calc(18px + env(safe-area-inset-bottom,0px));z-index:9999;pointer-events:none;font-family:system-ui,-apple-system,sans-serif}
.tien404-floating-widget>*{pointer-events:auto}
.tien404-chat-launcher{display:flex;align-items:center;justify-content:center;gap:9px;border:1px solid #a28cff;background:linear-gradient(135deg,#6047e8,#8b4de8);color:white;border-radius:999px;padding:13px 17px;min-height:56px;box-shadow:0 9px 30px #0008;font:700 15px system-ui,sans-serif;cursor:pointer}
.tien404-chat-launcher:focus-visible,.tien404-panel-head button:focus-visible{outline:3px solid #c4b5fd;outline-offset:3px}
.tien404-chat-panel[hidden]{display:none!important}
.tien404-chat-panel{position:absolute;bottom:70px;right:0;width:min(390px,calc(100vw - 24px));height:min(570px,calc(100dvh - 105px));display:flex;flex-direction:column;overflow:hidden;border:1px solid #6755b3;border-radius:18px;background:#101126;box-shadow:0 15px 55px #000a;color:#fff}
.tien404-panel-head{flex:0 0 auto;display:flex;justify-content:space-between;align-items:center;padding:10px 14px;background:#181a35;border-bottom:1px solid #403969}
.tien404-panel-head strong{display:block;font-size:15px}
.tien404-panel-head small{display:block;font-size:11px;color:#c7c4e6;margin-top:3px}
.tien404-panel-head button{min-width:42px;min-height:38px;border:1px solid #7263ae;border-radius:10px;background:#302c51;color:#fff;font-size:23px;cursor:pointer}
.tien404-chat-panel .ai-live-card{flex:1 1 auto;display:flex;flex-direction:column;min-height:0;overflow:hidden;border:0;border-radius:0;padding:0!important;box-shadow:none;background:#101126}
.tien404-chat-panel .tien404-ai-chat{flex:1 1 0%!important;height:auto!important;min-height:0!important;max-height:none!important;overflow:hidden}
.tien404-chat-panel #n8n-chat .chat-layout{height:100%;min-height:0}
.tien404-chat-panel #n8n-chat .chat-header{display:none!important}
.tien404-chat-panel #n8n-chat .chat-body{flex:1 1 0%;min-height:0;overflow-y:auto;overscroll-behavior:contain}
.tien404-chat-panel .tien404-composer{flex:0 0 auto;padding:8px!important}
@media(max-width:600px){
 .tien404-floating-widget{right:12px;bottom:calc(12px + env(safe-area-inset-bottom,0px))}
 .tien404-chat-panel{width:calc(100vw - 24px);height:min(530px,calc(100dvh - 105px));bottom:68px}
 .tien404-chat-panel .tien404-ai-chat{height:auto!important;min-height:0!important;max-height:none!important}
 .tien404-chat-panel .ai-live-card{padding:0!important}
 .tien404-chat-panel #n8n-chat .chat-body{overscroll-behavior:contain!important}
}
@media(max-height:550px){.tien404-chat-panel{height:calc(100dvh - 88px);bottom:62px}}


/* V8: concise live-AI CTA; the real chat lives in the floating launcher. */
.ai-live.ai-live--compact{padding:26px 0 38px;scroll-margin-top:98px}
.ai-live-compact-card{
  display:flex;align-items:center;justify-content:space-between;gap:22px;
  border:1px solid #51477e;border-radius:20px;
  background:linear-gradient(120deg,#18192f,#141529 65%,#201a41);
  padding:22px 26px;
}
.ai-live-compact-copy{max-width:690px;min-width:0}
.ai-live-compact-tag{display:inline-flex;align-items:center;gap:6px;font-size:10px;font-weight:750;letter-spacing:.08em;color:#77e9bd}
.ai-live-compact-tag span{font-size:10px}
.ai-live-compact-card h2{font-size:clamp(22px,2.8vw,28px);line-height:1.25;letter-spacing:-.03em;margin:6px 0}
.ai-live-compact-card p{font-size:14px;color:#d4d8ed;line-height:1.55;margin:0 0 6px}
.ai-live-compact-card small{font-size:11px;line-height:1.5;color:#a6abc7}
.ai-live-compact-button{
  flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;gap:9px;
  min-height:48px;padding:12px 18px;border:0;border-radius:12px;
  color:white;background:linear-gradient(110deg,#655df1,#9b45ec);
  font:700 14px/1.2 system-ui,sans-serif;cursor:pointer;
  box-shadow:0 8px 22px #6547c033;
}
.ai-live-compact-button:hover{filter:brightness(1.1)}
.ai-live-compact-button:focus-visible{outline:3px solid #cbb5ff;outline-offset:3px}
@media(max-width:600px){
  .ai-live.ai-live--compact{padding:18px 0 30px}
  .ai-live-compact-card{flex-direction:column;align-items:stretch;padding:18px;gap:16px;border-radius:16px}
  .ai-live-compact-card h2{font-size:22px}
  .ai-live-compact-card p{font-size:13px}
  .ai-live-compact-button{width:100%}
}
@media(prefers-reduced-motion:reduce){.ai-live-compact-button{transition:none}}
