:root{--chat-ink:#14343a;--chat-teal:#147b72;--chat-mint:#e8f5f0;--chat-gold:#d4aa55}
.ew-chat-page{box-sizing:border-box;width:min(780px,100% - 32px);margin:28px auto;background:#fff;border:1px solid #dfeae6;border-radius:22px;box-shadow:0 16px 50px #14343a12;overflow:hidden;color:var(--chat-ink);font-family:inherit}
.ew-chat-page *{box-sizing:border-box}.ew-chat-head{display:flex;justify-content:space-between;align-items:center;padding:18px 22px;background:linear-gradient(120deg,#10383d,#176e66);color:#fff}.ew-chat-head>div{display:flex;align-items:center;gap:12px}.ew-chat-head strong,.ew-chat-head small{display:block}.ew-chat-head strong{font-size:17px}.ew-chat-head small{opacity:.8;margin-top:3px}.ew-chat-mark{display:grid;place-items:center;width:42px;height:42px;border-radius:14px;background:linear-gradient(145deg,#f4d989,#b98c39);color:#16373a;font-weight:900}.ew-chat-logout{border:1px solid #ffffff55;color:#fff;background:#ffffff12;border-radius:10px;padding:9px 12px;cursor:pointer}
.ew-chat-start{padding:28px;display:grid;gap:15px}.ew-chat-start h1{margin:0;font-size:26px}.ew-chat-start p{margin:0;color:#64777a;line-height:1.65}.ew-chat-start label{display:grid;gap:7px;font-weight:650}.ew-chat-start input,.ew-chat-compose textarea,.ew-chat-admin input,.ew-chat-admin textarea,.ew-chat-admin select{font:inherit;border:1px solid #d5e3df;border-radius:11px;padding:12px;background:#fff;color:var(--chat-ink);width:100%}.ew-chat-start button,.ew-chat-admin button{border:0;border-radius:11px;padding:12px 16px;background:linear-gradient(120deg,#176f67,#10504f);color:#fff;font-weight:750;cursor:pointer}.ew-chat-room{padding:16px 18px 14px}.ew-chat-welcome{padding:12px 14px;border-radius:12px;background:#f1f7f5;color:#44615e;line-height:1.55}.ew-chat-messages{height:min(52vh,510px);min-height:250px;overflow:auto;display:flex;flex-direction:column;gap:10px;padding:16px 4px}.ew-chat-bubble{max-width:85%;padding:11px 14px;border-radius:15px;background:#f0f4f3;line-height:1.55;white-space:pre-wrap;overflow-wrap:anywhere}.ew-chat-bubble.mine{align-self:flex-end;background:#176f67;color:white;border-bottom-right-radius:5px}.ew-chat-bubble.theirs{align-self:flex-start;border-bottom-left-radius:5px}.ew-chat-bubble time{display:block;font-size:11px;opacity:.65;margin-top:5px}.ew-chat-compose{display:flex;align-items:end;gap:9px}.ew-chat-compose textarea{resize:vertical;min-height:48px;max-height:150px}.ew-chat-compose button{flex:0 0 48px;height:48px;border:0;border-radius:14px;background:#176f67;color:#fff;font-size:20px;cursor:pointer}.ew-chat-note{font-size:12px;color:#718180;margin:8px 2px 0}.ew-chat-error{color:#a43e34;font-size:13px;margin-top:8px}.ew-chat-embed{margin:0;background:#f7faf9}.ew-chat-embed .ew-chat-page{width:100%;height:100dvh;max-height:100dvh;margin:0;border:0;border-radius:0;box-shadow:none;display:flex;flex-direction:column}.ew-chat-embed .ew-chat-room{flex:1;min-height:0;display:flex;flex-direction:column}.ew-chat-embed .ew-chat-messages{flex:1;height:auto;min-height:0}
.ew-chat-admin{width:min(1320px,calc(100% - 32px));margin:24px auto;display:grid;grid-template-columns:minmax(260px,350px) minmax(0,1fr);gap:16px;color:var(--chat-ink)}.ew-chat-admin-panel{background:#fff;border:1px solid #dfe9e6;border-radius:16px;overflow:hidden}.ew-chat-admin-tools{padding:14px;display:grid;gap:9px;border-bottom:1px solid #e7efed}.ew-chat-conversations{max-height:70vh;overflow:auto}.ew-chat-conversation{width:100%;text-align:left;padding:14px;border:0;border-bottom:1px solid #edf2f0;background:#fff;cursor:pointer;color:inherit}.ew-chat-conversation.active{background:#eaf5f1}.ew-chat-conversation strong,.ew-chat-conversation small{display:block}.ew-chat-conversation small{margin-top:5px;color:#657977;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ew-chat-thread{height:min(75vh,760px);display:flex;flex-direction:column}.ew-chat-thread-title{padding:15px 18px;border-bottom:1px solid #e7efed}.ew-chat-thread-title strong,.ew-chat-thread-title small{display:block}.ew-chat-thread-title small{color:#64777a;margin-top:4px}.ew-chat-admin-messages{flex:1;overflow:auto;padding:16px;display:flex;flex-direction:column;gap:9px}.ew-chat-admin .ew-chat-compose{padding:12px;border-top:1px solid #e7efed}.ew-chat-admin-actions{display:flex;gap:8px;flex-wrap:wrap;padding:0 12px 12px}.ew-chat-admin-actions button{font-size:12px;padding:8px 10px}.ew-chat-admin-actions .secondary{background:#edf5f2;color:#174944}.ew-chat-config{max-width:900px;margin:24px auto;padding:22px;background:#fff;border:1px solid #dfe9e6;border-radius:16px;display:grid;gap:15px}.ew-chat-config label{display:grid;gap:7px}.ew-chat-config textarea{min-height:110px}.ew-chat-kb-row{display:grid;grid-template-columns:1fr auto;gap:8px;align-items:start;margin:10px 0}.ew-chat-kb-row textarea{min-height:70px}.ew-chat-config .notice{padding:10px;border-radius:9px;background:#eaf5f1}
@media(max-width:760px){.ew-chat-admin{grid-template-columns:1fr}.ew-chat-conversations{max-height:34vh}.ew-chat-thread{height:64vh}.ew-chat-page{margin:12px auto}.ew-chat-start{padding:22px}.ew-chat-room{padding:12px}}
 .ew-chat-note button{border:0;padding:0;background:transparent;color:#176f67;text-decoration:underline;font:inherit;cursor:pointer}
.ew-chat-request-toggle{width:100%;margin-top:10px;border:1px solid #c9ddd6;border-radius:12px;padding:11px 14px;background:linear-gradient(110deg,#f2ead3,#fffaf0);color:#174944;font:inherit;font-weight:750;cursor:pointer}.ew-chat-request{margin-top:12px;padding:14px;border:1px solid #dce9e4;border-radius:14px;background:#fbfdfc;display:grid;gap:9px;max-width:100%;overflow:visible}.ew-chat-request[hidden]{display:none}.ew-chat-request h2{margin:0;font-size:18px}.ew-chat-request p{margin:0;color:#687b77;font-size:12px;line-height:1.45}.ew-chat-request label{display:grid;gap:6px;font-size:13px;font-weight:650}.ew-chat-request input,.ew-chat-request select,.ew-chat-request textarea{width:100%;min-width:0;border:1px solid #d5e3df;border-radius:10px;padding:10px;background:#fff;color:var(--chat-ink);font:inherit}.ew-chat-request textarea{min-height:72px;resize:vertical}.ew-chat-request button[type=submit]{border:0;border-radius:10px;padding:12px;background:linear-gradient(120deg,#176f67,#10504f);color:#fff;font:inherit;font-weight:750;cursor:pointer}.ew-chat-request button:disabled{opacity:.6;cursor:wait}
.ew-chat-embed .ew-chat-room{overflow-y:auto;overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch;scrollbar-gutter:stable}
.ew-chat-embed .ew-chat-request{flex:0 0 auto}
@media(max-width:760px){.ew-chat-embed .ew-chat-room{padding-bottom:max(12px,env(safe-area-inset-bottom));overflow-y:auto}.ew-chat-embed .ew-chat-request{padding:12px;gap:8px}.ew-chat-request input,.ew-chat-request select{padding:9px}.ew-chat-request button[type=submit]{padding:11px;min-height:44px}.ew-chat-page{width:calc(100% - 20px);margin:10px auto;border-radius:16px}.ew-chat-head{padding:13px 14px}.ew-chat-start{padding:18px}.ew-chat-room{padding:10px 12px}.ew-chat-messages{min-height:220px;height:42vh}.ew-chat-compose textarea{max-height:120px}.ew-chat-request{margin-bottom:8px}}
.ew-chat-ai-error{display:block;margin-top:7px;padding:7px 9px;border-radius:8px;background:#fff0ed;color:#8c3128;font-size:11px;line-height:1.4;overflow-wrap:anywhere}

/* Searchable Store picker for Product Request */
.ew-chat-store-picker{position:relative;width:100%}.ew-chat-store-input-row{display:flex;gap:7px;align-items:stretch}.ew-chat-store-input-row input[type=text]{flex:1;min-width:0}.ew-chat-store-search{width:42px;min-width:42px;padding:0!important;border:1px solid #c9ddd6!important;border-radius:10px!important;background:#eef7f3!important;color:#176f67!important;font-size:22px!important;line-height:1;cursor:pointer}.ew-chat-store-options{position:absolute;z-index:30;left:0;right:0;top:calc(100% + 5px);max-height:230px;overflow-y:auto;border:1px solid #d5e3df;border-radius:11px;background:#fff;box-shadow:0 8px 22px rgba(23,73,68,.12);padding:5px}.ew-chat-store-options[hidden]{display:none}.ew-chat-store-option{width:100%;display:flex;align-items:center;justify-content:space-between;gap:10px;text-align:left;border:0;border-bottom:1px solid #edf3f1;background:#fff;color:var(--chat-ink);padding:10px 9px;border-radius:7px;cursor:pointer;font:inherit}.ew-chat-store-option:last-child{border-bottom:0}.ew-chat-store-option:hover,.ew-chat-store-option:focus{background:#f0f8f5;outline:none}.ew-chat-store-option strong{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ew-chat-store-option small{flex:0 0 auto;color:#71827e;font-size:11px}.ew-chat-store-empty{padding:12px 9px;text-align:center;color:#788985;font-size:12px}.ew-chat-store-field{min-width:0}

/* Final chat application layout */
.ew-chat-messages .ew-chat-welcome{flex:0 0 auto;order:-1;padding:12px 14px;border-radius:12px;background:#f1f7f5;color:#44615e;line-height:1.55}
.ew-chat-embed{height:100dvh;min-height:100dvh;overflow:hidden}
.ew-chat-embed .ew-chat-page{height:100dvh;min-height:100dvh}
.ew-chat-host .ew-chat-page{margin-top:18px}
@media(max-width:760px){
  body.ew-chat-host{padding-bottom:0}
  body.ew-chat-host .ew-chat-page{width:100%;margin:0;border-radius:0;min-height:calc(100dvh - 63px);box-shadow:none}
  body.ew-chat-host .ew-chat-head{position:static}
  .ew-chat-embed .ew-chat-page{height:100dvh;border-radius:0}
  .ew-chat-embed .ew-chat-room{padding:8px 10px max(10px,env(safe-area-inset-bottom));}
  .ew-chat-embed .ew-chat-messages{min-height:0;height:auto;flex:1;padding:10px 2px}
  .ew-chat-compose{position:sticky;bottom:0;background:#f7faf9;padding-top:7px}
}
/* Admin chat application */
.ew-chat-admin{grid-template-columns:320px minmax(0,1fr);align-items:stretch}
.ew-chat-admin-panel{box-shadow:0 10px 35px #14343a0b}
.ew-chat-admin-tools h2{margin:0;font-size:19px}.ew-chat-admin-tools:before{content:'Live customer support';display:block;color:#08786d;font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.08em}
.ew-chat-conversation{position:relative;display:block;min-height:76px;padding:13px 14px}.ew-chat-conversation.active{box-shadow:inset 4px 0 #08786d}
.ew-chat-conversation strong{font-size:14px}.ew-chat-conversation small{line-height:1.45}
.ew-chat-thread{min-height:650px}.ew-chat-thread-title{display:flex;align-items:center;justify-content:space-between;gap:10px;background:#f8fbfa}.ew-chat-thread-title strong{font-size:16px}.ew-chat-thread-title small{font-size:12px}
.ew-chat-admin-messages{background:linear-gradient(#fbfdfc,#f6faf8)}
.ew-chat-admin-messages .ew-chat-bubble{box-shadow:0 2px 8px #14343a08}.ew-chat-admin-messages .ew-chat-bubble.mine{align-self:flex-end}.ew-chat-admin-messages .ew-chat-bubble.theirs{align-self:flex-start}
.ew-chat-admin-actions{border-top:1px solid #e7efed;padding-top:10px}
@media(max-width:760px){.ew-chat-admin{width:calc(100% - 16px);margin:10px auto;grid-template-columns:1fr}.ew-chat-admin-tools{position:sticky;top:0;z-index:2}.ew-chat-conversations{max-height:38vh}.ew-chat-thread{height:62vh;min-height:500px}.ew-chat-thread-title{position:sticky;top:0;z-index:1}.ew-chat-admin-actions{padding-bottom:10px}.ew-chat-admin .ew-chat-compose textarea{min-height:46px}}

/* Final customer-chat admin application UI */
.ew-chat-admin{width:min(1380px,calc(100% - 32px));margin:20px auto;grid-template-columns:340px minmax(0,1fr);gap:18px;min-height:calc(100dvh - 150px)}
.ew-chat-inbox,.ew-chat-thread{min-width:0;background:#fff;border:1px solid #dce9e4;border-radius:18px;box-shadow:0 14px 40px rgba(20,55,59,.08)}
.ew-chat-inbox{display:flex;flex-direction:column;overflow:hidden}
.ew-chat-admin-tools{padding:18px;border-bottom:1px solid #e7efed;background:linear-gradient(180deg,#fbfefd,#f5faf8);position:relative}
.ew-chat-admin-heading{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}.ew-chat-admin-heading h2{margin:2px 0 3px;font-size:21px;color:#173b3f}.ew-chat-admin-heading p{margin:0;color:#6b7d7a;font-size:12px;line-height:1.45}.ew-chat-admin-eyebrow{display:block;color:#08786d;font-size:10px;font-weight:850;letter-spacing:.09em;text-transform:uppercase}
.ew-chat-admin-heading #chatNotify{width:38px;height:38px;padding:0;border-radius:11px;background:#edf7f3;color:#176f67}
.ew-chat-search{display:flex;align-items:center;gap:8px;margin-top:15px;padding:0 11px;border:1px solid #d4e3de;border-radius:12px;background:#fff}.ew-chat-search span{color:#08786d;font-size:20px}.ew-chat-search input{border:0!important;padding:11px 2px!important;outline:0!important;background:transparent!important}
.ew-chat-filter{display:flex!important;align-items:center!important;gap:8px!important;margin-top:10px;color:#5e7370;font-size:12px;font-weight:650}.ew-chat-filter input{width:auto!important}
.ew-chat-inbox-summary{display:flex;justify-content:space-between;padding:11px 15px;background:#f8fbfa;border-bottom:1px solid #e7efed;color:#71827f;font-size:11px}.ew-chat-inbox-summary strong{color:#173b3f;font-size:14px}
.ew-chat-conversations{flex:1;max-height:none;overflow:auto;padding:5px}
.ew-chat-conversation{margin:2px 0;width:100%;border:0;border-radius:13px!important;padding:12px 11px!important;background:#fff!important}.ew-chat-conversation:hover{background:#f4faf7!important}.ew-chat-conversation.active{background:#e7f5ef!important;box-shadow:inset 4px 0 #08786d}.ew-chat-conversation-head{display:flex;align-items:center;justify-content:space-between;gap:8px}.ew-chat-conversation strong{font-size:14px;color:#173b3f}.ew-chat-conversation small{margin-top:5px;color:#607572;font-size:12px}.ew-chat-conversation em{display:block;margin-top:4px;color:#8a9996;font-size:10px;font-style:normal}.ew-chat-conversation-tags{display:flex;gap:5px;margin-top:7px}.ew-chat-conversation-tags span,.status-chip{display:inline-flex;align-items:center;padding:3px 7px;border-radius:999px;background:#edf7f3;color:#176f67;font-size:9px;font-weight:800}.ew-chat-conversation-tags .dispatch,.status-chip.dispatch{background:#fff5df;color:#9a6810}.ew-chat-unread{min-width:21px;height:21px;display:grid;place-items:center;border-radius:999px;background:#d09c32;color:#fff;font-size:10px;font-weight:850}.ew-chat-list-empty{padding:35px 18px;text-align:center;color:#788985;font-size:13px}
.ew-chat-thread{height:calc(100dvh - 150px);min-height:650px;display:flex;flex-direction:column;overflow:hidden}
.ew-chat-thread-title{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:12px;padding:14px 18px;border-bottom:1px solid #e7efed;background:#fbfefd}.ew-chat-back{display:none!important;white-space:nowrap}.ew-chat-thread-identity{display:flex;align-items:center;gap:11px;min-width:0}.ew-chat-thread-identity>span:last-child{min-width:0}.ew-chat-thread-identity strong,.ew-chat-thread-identity small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ew-chat-thread-identity strong{font-size:16px;color:#173b3f}.ew-chat-thread-identity small{margin-top:3px;color:#6c7e7b;font-size:11px}.ew-chat-avatar{width:42px!important;height:42px;flex:0 0 42px;display:grid;place-items:center;border-radius:13px;background:linear-gradient(135deg,#176f67,#0d554f);color:#fff;font-weight:850;font-size:17px}.ew-chat-thread-status{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:5px}
.ew-chat-customer-card{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;padding:11px 18px;background:#f5faf8;border-bottom:1px solid #e7efed}.ew-chat-customer-card>div{padding:8px 10px;border:1px solid #dce9e4;border-radius:10px;background:#fff}.ew-chat-customer-card span,.ew-chat-customer-card strong{display:block}.ew-chat-customer-card span{font-size:9px;color:#80908d;text-transform:uppercase;letter-spacing:.05em}.ew-chat-customer-card strong{margin-top:3px;font-size:12px;color:#31524e;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ew-chat-admin-messages{flex:1;min-height:0;overflow:auto;padding:20px 22px;display:flex;flex-direction:column;gap:10px;background:linear-gradient(180deg,#fbfdfc,#f5faf8)}.ew-chat-admin-message-row{display:flex;flex-direction:column;max-width:min(78%,720px)}.ew-chat-admin-message-row.outgoing{align-self:flex-end;align-items:flex-end}.ew-chat-admin-message-row.incoming{align-self:flex-start;align-items:flex-start}.ew-chat-message-label{margin:0 4px 4px;color:#80908d;font-size:9px;font-weight:800;text-transform:uppercase;letter-spacing:.05em}.ew-chat-admin-messages .ew-chat-bubble{max-width:100%;box-shadow:0 3px 12px rgba(20,55,59,.05)}.ew-chat-message-actions{display:flex;gap:5px;margin-top:4px}.ew-chat-message-actions button{padding:4px 7px;border:0;border-radius:7px;background:#edf4f1;color:#42605b;font-size:9px;cursor:pointer}.ew-chat-edited{display:block;margin-top:4px;font-size:9px;opacity:.65}.ew-chat-admin-empty{margin:auto;max-width:340px;padding:30px;text-align:center;color:#71827f}.ew-chat-admin-empty span{display:block;font-size:38px;margin-bottom:10px}.ew-chat-admin-empty strong,.ew-chat-admin-empty small{display:block}.ew-chat-admin-empty strong{color:#31524e;font-size:16px}.ew-chat-admin-empty small{margin-top:6px;line-height:1.6}
.ew-chat-admin-compose{padding:12px 16px;border-top:1px solid #e1ece8;background:#fff}.ew-chat-admin-compose textarea{min-height:48px}.ew-chat-admin-compose button{min-width:110px}.ew-chat-admin-actions{display:flex;gap:8px;flex-wrap:wrap;padding:0 16px 14px;background:#fff}.ew-chat-admin-actions button{font-size:11px;padding:8px 10px}.ew-chat-admin-actions button:disabled{opacity:.45;cursor:not-allowed}
@media(max-width:760px){
  .ew-chat-admin{width:100%;margin:0;display:block;min-height:calc(100dvh - 76px)}
  .ew-chat-inbox,.ew-chat-thread{border-radius:0;border-left:0;border-right:0;box-shadow:none;min-height:calc(100dvh - 76px)}
  .ew-chat-thread{display:none;height:calc(100dvh - 76px)}
  .ew-chat-admin.mobile-thread-open .ew-chat-inbox{display:none}.ew-chat-admin.mobile-thread-open .ew-chat-thread{display:flex}
  .ew-chat-admin-tools{padding:15px}.ew-chat-conversations{max-height:none}.ew-chat-conversation{padding:13px 12px!important}
  .ew-chat-back{display:inline-flex!important;padding:8px 10px!important;font-size:11px!important;background:#edf5f2!important;color:#174944!important}
  .ew-chat-thread-title{grid-template-columns:auto minmax(0,1fr);padding:11px 12px}.ew-chat-thread-status{grid-column:2;justify-content:flex-start}.ew-chat-avatar{width:38px!important;height:38px;flex-basis:38px}.ew-chat-thread-identity strong{font-size:14px}.ew-chat-customer-card{grid-template-columns:1fr 1fr;padding:9px 12px}.ew-chat-customer-card>div:last-child{grid-column:1/-1}.ew-chat-admin-messages{padding:14px 12px}.ew-chat-admin-message-row{max-width:88%}.ew-chat-admin-compose{padding:9px 10px}.ew-chat-admin-compose textarea{min-height:45px}.ew-chat-admin-actions{padding:0 10px 10px}.ew-chat-admin-actions button{flex:1}
}

/* UI-only refinement: keep the owner navigation visible beside Customer Chat. */
.ew-admin-chat-shell{grid-template-columns:220px minmax(0,1fr);align-items:stretch;gap:18px;min-width:0}
.ew-admin-chat-sidebar{align-self:start;position:sticky;top:104px;z-index:5}
.ew-admin-chat-maincol{min-width:0}
.ew-admin-chat-maincol>.ew-chat-admin{width:100%;max-width:none;margin:0;min-height:calc(100dvh - 175px);grid-template-columns:330px minmax(0,1fr);gap:14px}
.ew-admin-chat-maincol .ew-chat-thread{height:calc(100dvh - 175px);min-height:620px}
.ew-admin-chat-maincol .ew-chat-admin-messages{min-height:360px}
.ew-admin-chat-maincol .ew-chat-customer-card{grid-template-columns:repeat(3,minmax(0,1fr))}

/* Do not let the admin polling cycle move an administrator who is reading older messages. */
.ew-chat-admin-messages{overflow-anchor:none;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}

/* Customer send button: make the request visibly working immediately. */
.ew-chat-compose button.is-sending,
.ew-chat-compose button:disabled.is-sending{cursor:wait;opacity:.9;display:grid;place-items:center}
.ew-chat-send-spinner{width:19px;height:19px;border:2px solid rgba(255,255,255,.45);border-top-color:#fff;border-radius:50%;animation:ewChatSpin .75s linear infinite;display:block}
@keyframes ewChatSpin{to{transform:rotate(360deg)}}

/* Keep the Product Request control fully visible in the embedded/mobile chat. */
.ew-chat-embed .ew-chat-compose,
.ew-chat-embed .ew-chat-request-toggle,
.ew-chat-embed .ew-chat-note,
.ew-chat-embed #chatError{flex:0 0 auto}
.ew-chat-embed .ew-chat-request-toggle{display:block;min-height:46px;margin:8px 0 0;width:100%;white-space:normal;line-height:1.3}

@media(max-width:760px){
  .ew-admin-chat-shell{display:block;width:100%;padding-top:0}
  .ew-admin-chat-sidebar{position:static;margin:0 0 10px;overflow-x:auto;display:flex;gap:4px;padding:7px;white-space:nowrap}
  .ew-admin-chat-sidebar>strong{flex:0 0 auto}
  .ew-admin-chat-sidebar a{flex:0 0 auto}
  .ew-admin-chat-maincol>.ew-chat-admin{min-height:calc(100dvh - 120px);grid-template-columns:1fr}
  .ew-admin-chat-maincol .ew-chat-thread{height:calc(100dvh - 120px);min-height:620px}
  .ew-admin-chat-maincol .ew-chat-admin-messages{min-height:360px}
  .ew-admin-chat-maincol .ew-chat-customer-card{grid-template-columns:1fr 1fr}
}

/* Customer Chat UI refinement 2: prioritize the actual customer list and conversation. */
.ew-admin-chat-maincol .ew-chat-inbox,
.ew-admin-chat-maincol .ew-chat-thread{
  min-height:720px;
}
.ew-admin-chat-maincol .ew-chat-inbox{
  height:min(820px,calc(100dvh - 120px));
}
.ew-admin-chat-maincol .ew-chat-admin-tools-minimal{
  padding:14px;
  background:#fff;
  border-bottom:1px solid #e7efed;
}
.ew-admin-chat-maincol .ew-chat-conversations{
  flex:1;
  max-height:none;
  overflow:auto;
}
.ew-admin-chat-maincol .ew-chat-thread{
  height:min(820px,calc(100dvh - 120px));
  min-height:720px;
}
/* Hide the secondary metadata card: it was consuming the space needed for messages. */
.ew-admin-chat-maincol .ew-chat-customer-card{display:none!important}
.ew-admin-chat-maincol .ew-chat-thread-title{
  flex:0 0 auto;
  display:grid;
  grid-template-columns:auto minmax(0,1fr) auto;
  min-height:68px;
  padding:10px 14px;
  background:#fff;
}
.ew-admin-chat-maincol .ew-chat-thread-identity{gap:9px}
.ew-admin-chat-maincol .ew-chat-thread-identity strong{font-size:17px}
.ew-admin-chat-maincol .ew-chat-thread-identity small{font-size:11px}
.ew-admin-chat-maincol .ew-chat-avatar{width:38px!important;height:38px;flex-basis:38px;font-size:15px}
.ew-admin-chat-maincol .ew-chat-admin-messages{
  flex:1 1 auto;
  min-height:600px;
  padding:20px 22px;
  gap:13px;
  background:#f7fbf9;
}
.ew-admin-chat-maincol .ew-chat-admin-message-row{max-width:86%}
.ew-admin-chat-maincol .ew-chat-admin-messages .ew-chat-bubble{
  font-size:14px;
  line-height:1.65;
  padding:13px 16px;
  border-radius:14px;
}
.ew-admin-chat-maincol .ew-chat-admin-compose{flex:0 0 auto}
.ew-admin-chat-maincol .ew-chat-admin-actions{flex:0 0 auto}

@media(max-width:760px){
  .ew-admin-chat-maincol .ew-chat-inbox,
  .ew-admin-chat-maincol .ew-chat-thread{
    min-height:calc(100dvh - 90px);
    height:calc(100dvh - 90px);
  }
  .ew-admin-chat-maincol .ew-chat-admin-messages{
    min-height:0;
    padding:16px 12px;
  }
  .ew-admin-chat-maincol .ew-chat-admin-message-row{max-width:94%}
  .ew-admin-chat-maincol .ew-chat-admin-messages .ew-chat-bubble{
    font-size:14px;
    line-height:1.6;
  }
}

/* Customer chat reading view: keep the conversation itself as the primary UI. */
.ew-admin-chat-maincol .ew-chat-thread-title{
  min-height:0;
  padding:0;
  border:0;
  background:transparent;
  display:block;
}
.ew-admin-chat-maincol .ew-chat-thread-identity,
.ew-admin-chat-maincol .ew-chat-thread-status,
.ew-admin-chat-maincol .ew-chat-customer-card{
  display:none !important;
}
.ew-admin-chat-maincol .ew-chat-back{
  display:none !important;
}
.ew-admin-chat-maincol .ew-chat-thread{
  height:calc(100dvh - 150px);
  min-height:700px;
}
.ew-admin-chat-maincol .ew-chat-admin-messages{
  flex:1 1 auto;
  min-height:600px;
  height:600px;
  padding:24px 28px;
  gap:14px;
  background:#f7faf9;
  overflow-y:auto;
}
.ew-admin-chat-maincol .ew-chat-admin-message-row{
  width:fit-content;
  max-width:min(78%,760px);
}
.ew-admin-chat-maincol .ew-chat-admin-message-row.incoming{
  align-self:flex-start;
  align-items:flex-start;
}
.ew-admin-chat-maincol .ew-chat-admin-message-row.outgoing{
  align-self:flex-end;
  align-items:flex-end;
}
.ew-admin-chat-maincol .ew-chat-message-label{
  font-size:11px;
  margin:0 8px 5px;
  letter-spacing:.03em;
  text-transform:none;
  color:#6d817d;
}
.ew-admin-chat-maincol .ew-chat-bubble{
  max-width:100%;
  padding:13px 16px;
  border-radius:16px;
  font-size:15px;
  line-height:1.6;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
  box-shadow:0 2px 8px rgba(20,55,59,.07);
}
/* Customer: left side */
.ew-admin-chat-maincol .ew-chat-admin-message-row.incoming .ew-chat-bubble{
  background:#e9eff1;
  color:#19383c;
  border-bottom-left-radius:5px;
}
/* AI/admin: right side */
.ew-admin-chat-maincol .ew-chat-admin-message-row.outgoing .ew-chat-bubble{
  background:#14756d;
  color:#fff;
  border-bottom-right-radius:5px;
}
.ew-admin-chat-maincol .ew-chat-bubble time{
  font-size:10px;
  margin-top:7px;
  opacity:.62;
}
.ew-admin-chat-maincol .ew-chat-message-actions{
  margin-top:5px;
  gap:5px;
}
.ew-admin-chat-maincol .ew-chat-message-actions button{
  font-size:10px;
  padding:5px 8px;
}
.ew-admin-chat-maincol .ew-chat-admin-compose{
  flex:0 0 auto;
  padding:12px 14px;
}

@media(max-width:760px){
  .ew-admin-chat-maincol .ew-chat-thread-title{
    position:relative;
  }
  .ew-admin-chat-maincol .ew-chat-back{
    display:inline-flex !important;
    margin:8px 10px 0;
    padding:8px 12px;
  }
  .ew-admin-chat-maincol .ew-chat-admin-messages{
    min-height:500px;
    height:auto;
    flex:1 1 auto;
    padding:16px 12px;
  }
  .ew-admin-chat-maincol .ew-chat-admin-message-row{
    max-width:92%;
  }
  .ew-admin-chat-maincol .ew-chat-bubble{
    font-size:15px;
    padding:12px 14px;
  }
}

/* FINAL ADMIN CHAT READING LAYOUT: messages are the primary view. */
.ew-admin-chat-maincol .ew-chat-thread{
  position:relative;
  display:flex;
  flex-direction:column;
  height:min(860px,calc(100dvh - 105px));
  min-height:700px;
  overflow:hidden;
}
.ew-admin-chat-maincol .ew-chat-admin-messages{
  order:1;
  flex:1 1 auto;
  height:auto;
  min-height:600px;
  margin:0;
  padding:24px 28px;
  overflow-y:auto;
  overscroll-behavior:contain;
  background:#f7faf9;
}
.ew-admin-chat-maincol .ew-chat-admin-compose{
  order:2;
  flex:0 0 auto;
  margin:0;
  padding:12px 14px;
  background:#fff;
  border-top:1px solid #e5eeeb;
}
.ew-admin-chat-maincol .ew-chat-admin-actions{
  order:3;
  flex:0 0 auto;
  padding:0 14px 12px;
  background:#fff;
}
/* No customer details/header should consume message space. */
.ew-admin-chat-maincol .ew-chat-thread-title,
.ew-admin-chat-maincol .ew-chat-customer-card{display:none!important}
/* Back is only a mobile overlay; it does not consume message height. */
.ew-admin-chat-maincol .ew-chat-back{
  display:none!important;
  position:absolute;
  z-index:20;
  top:10px;
  left:10px;
  margin:0;
  padding:8px 12px;
  box-shadow:0 3px 12px rgba(0,0,0,.12);
}
.ew-admin-chat-maincol .ew-chat-admin-message-row.incoming{align-self:flex-start;align-items:flex-start}
.ew-admin-chat-maincol .ew-chat-admin-message-row.outgoing{align-self:flex-end;align-items:flex-end}
.ew-admin-chat-maincol .ew-chat-admin-message-row{width:fit-content;max-width:min(78%,760px)}
.ew-admin-chat-maincol .ew-chat-admin-messages .ew-chat-bubble{
  font-size:15px;
  line-height:1.65;
  padding:14px 17px;
  border-radius:16px;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}
.ew-admin-chat-maincol .ew-chat-admin-message-row.incoming .ew-chat-bubble{
  background:#e8eef0;
  color:#17383d;
  border-bottom-left-radius:5px;
}
.ew-admin-chat-maincol .ew-chat-admin-message-row.outgoing .ew-chat-bubble{
  background:#14756d;
  color:#fff;
  border-bottom-right-radius:5px;
}
@media(max-width:760px){
  .ew-admin-chat-maincol .ew-chat-thread{
    height:calc(100dvh - 90px);
    min-height:0;
  }
  .ew-admin-chat-maincol .ew-chat-admin-messages{
    min-height:500px;
    height:auto;
    padding:18px 12px;
  }
  .ew-admin-chat-maincol .ew-chat-back{display:inline-flex!important}
  .ew-admin-chat-maincol .ew-chat-admin-message-row{max-width:92%}
}


/* Final UI pass: selected customer must remain clearly readable. */
.ew-admin-chat-maincol .ew-chat-conversation.active,
.ew-admin-chat-maincol .ew-chat-conversation.active:hover,
.ew-admin-chat-maincol .ew-chat-conversation.active:focus-visible{
  background:#dff3eb!important;
  color:#123b3b!important;
  border-color:#86cbb9!important;
  box-shadow:inset 4px 0 0 #08786d, 0 4px 14px rgba(8,120,109,.10)!important;
}
.ew-admin-chat-maincol .ew-chat-conversation.active strong,
.ew-admin-chat-maincol .ew-chat-conversation.active p,
.ew-admin-chat-maincol .ew-chat-conversation.active small,
.ew-admin-chat-maincol .ew-chat-conversation.active em{
  color:#123b3b!important;
  opacity:1!important;
  text-shadow:none!important;
}
.ew-admin-chat-maincol .ew-chat-conversation.active strong{font-weight:850!important}
.ew-admin-chat-maincol .ew-chat-conversation.active p{font-weight:600!important}
.ew-admin-chat-maincol .ew-chat-conversation.active small,
.ew-admin-chat-maincol .ew-chat-conversation.active em{font-weight:750!important}
.ew-admin-chat-maincol .ew-chat-conversation.active .ew-chat-unread{
  background:#08786d!important;color:#fff!important;
}

/* Give the selected conversation a genuinely large reading area. */
.ew-admin-chat-maincol .ew-chat-thread{
  height:min(930px,calc(100dvh - 95px))!important;
  min-height:850px!important;
}
.ew-admin-chat-maincol .ew-chat-admin-messages{
  min-height:750px!important;
  padding:26px 30px!important;
}
@media(max-width:760px){
  .ew-admin-chat-maincol .ew-chat-thread{
    height:calc(100dvh - 68px)!important;
    min-height:0!important;
  }
  .ew-admin-chat-maincol .ew-chat-admin-messages{
    min-height:600px!important;
    padding:18px 12px!important;
  }
}

.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}


/* Final stability pass: the admin chat thread is the reading surface. */
.ew-admin-chat-maincol .ew-chat-thread{min-height:850px!important;height:min(930px,calc(100dvh - 95px))!important}
.ew-admin-chat-maincol .ew-chat-admin-messages{min-height:750px!important;overflow-y:auto!important;scroll-behavior:auto!important}
.ew-admin-chat-maincol .ew-chat-admin-message-row.incoming{align-self:flex-start!important;align-items:flex-start!important}
.ew-admin-chat-maincol .ew-chat-admin-message-row.outgoing{align-self:flex-end!important;align-items:flex-end!important}
.ew-admin-chat-maincol .ew-chat-admin-message-row.incoming .ew-chat-bubble{background:#e7eef0!important;color:#17383d!important}
.ew-admin-chat-maincol .ew-chat-admin-message-row.outgoing .ew-chat-bubble{background:#14756d!important;color:#fff!important}
.ew-admin-chat-maincol .ew-chat-conversation.active,
.ew-admin-chat-maincol .ew-chat-conversation.active:hover,
.ew-admin-chat-maincol .ew-chat-conversation.active:focus-visible{background:#dff3eb!important;color:#123b3b!important}
.ew-admin-chat-maincol .ew-chat-conversation.active strong,
.ew-admin-chat-maincol .ew-chat-conversation.active p,
.ew-admin-chat-maincol .ew-chat-conversation.active small,
.ew-admin-chat-maincol .ew-chat-conversation.active em{color:#123b3b!important;opacity:1!important}
@media(max-width:760px){
  .ew-admin-chat-maincol .ew-chat-thread{height:calc(100dvh - 68px)!important;min-height:0!important}
  .ew-admin-chat-maincol .ew-chat-admin-messages{min-height:600px!important;padding:18px 12px!important}
}
