.edm-chat-launcher{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:9999;
  border:0;
  background:#f2531e;
  color:#111;
  padding:14px 18px;
  border-radius:8px;
  font-weight:800;
  font-family:Poppins,Arial,sans-serif;
  box-shadow:0 14px 35px rgba(0,0,0,.22);
  cursor:pointer;
}
.edm-chat-panel{
  position:fixed;
  right:22px;
  bottom:82px;
  width:370px;
  max-width:calc(100vw - 28px);
  height:560px;
  max-height:calc(100vh - 105px);
  z-index:9999;
  background:#fff;
  border:1px solid rgba(15,23,42,.12);
  border-radius:12px;
  overflow:hidden;
  box-shadow:0 22px 60px rgba(0,0,0,.28);
  display:none;
  font-family:Poppins,Arial,sans-serif;
}
.edm-chat-panel.open{
  display:flex;
  flex-direction:column;
}
.edm-chat-head{
  background:#111827;
  color:#fff;
  padding:14px 16px;
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:center;
}
.edm-chat-title{
  font-weight:800;
  font-size:15px;
}
.edm-chat-sub{
  font-size:11px;
  color:#d1d5db;
  margin-top:2px;
}
.edm-chat-close{
  background:transparent;
  border:0;
  color:#fff;
  font-size:22px;
  cursor:pointer;
  line-height:1;
}
.edm-chat-body{
  flex:1;
  overflow:auto;
  background:#f6f7f9;
  padding:14px;
}
.edm-chat-msg{
  max-width:82%;
  margin:0 0 10px;
  padding:10px 12px;
  border-radius:10px;
  font-size:13px;
  line-height:1.45;
  box-shadow:0 1px 2px rgba(0,0,0,.05);
}
.edm-chat-msg.bot,
.edm-chat-msg.system{
  background:#fff;
  color:#111827;
  border:1px solid #e5e7eb;
}
.edm-chat-msg.customer{
  background:#f2531e;
  color:#111;
  margin-left:auto;
  font-weight:600;
}
.edm-chat-msg.agent{
  background:#111827;
  color:#fff;
  margin-left:auto;
}
.edm-chat-meta{
  font-size:10px;
  opacity:.7;
  margin-bottom:3px;
}
.edm-chat-quick{
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  padding:10px 12px;
  background:#fff;
  border-top:1px solid #e5e7eb;
}
.edm-chat-quick button{
  border:1px solid #f2531e;
  background:#fff;
  color:#111827;
  border-radius:6px;
  padding:7px 9px;
  font-size:12px;
  font-weight:700;
  cursor:pointer;
}
.edm-chat-form{
  padding:12px;
  background:#fff;
  border-top:1px solid #e5e7eb;
  display:grid;
  gap:8px;
}
.edm-chat-fields{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:7px;
}
.edm-chat-form input,
.edm-chat-form textarea{
  width:100%;
  box-sizing:border-box;
  border:1px solid #d1d5db;
  border-radius:6px;
  padding:9px 10px;
  font:13px Poppins,Arial,sans-serif;
}
.edm-chat-form textarea{
  resize:none;
  height:58px;
  grid-column:1/-1;
}
.edm-chat-send{
  background:#111827;
  color:#fff;
  border:0;
  border-radius:6px;
  padding:10px 12px;
  font-weight:800;
  cursor:pointer;
}
@media(max-width:520px){
  .edm-chat-panel{
    right:10px;
    left:10px;
    width:auto;
    bottom:75px;
    height:calc(100vh - 95px);
  }
  .edm-chat-launcher{
    right:12px;
    bottom:14px;
  }
}


.edm-chat-form input[type="file"]{
  grid-column:1/-1;
  background:#f9fafb;
}
.edm-chat-msg a{
  color:inherit;
  text-decoration:underline;
}


.edm-chat-agent-status{
  padding:8px 12px;
  font-size:11px;
  font-weight:700;
  border-bottom:1px solid #e5e7eb;
  background:#f9fafb;
  color:#374151;
}
.edm-chat-agent-status.online{
  background:#dcfce7;
  color:#166534;
}
.edm-chat-agent-status.offline{
  background:#fff7ed;
  color:#9a3412;
}


.edm-chat-head-actions{
  display:flex;
  align-items:center;
  gap:8px;
}
.edm-chat-end{
  border:1px solid rgba(255,255,255,.35);
  background:transparent;
  color:#fff;
  border-radius:6px;
  padding:6px 9px;
  font:800 11px Poppins,Arial,sans-serif;
  cursor:pointer;
}
.edm-chat-end:hover{
  background:rgba(255,255,255,.08);
}


.edm-chat-customer-card{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border:1px solid #e5e7eb;
  border-radius:8px;
  background:#fff7ed;
}
.edm-chat-customer-card.complete{
  background:#f9fafb;
}
.edm-chat-customer-title{
  font-size:12px;
  font-weight:900;
  color:#111827;
}
.edm-chat-customer-sub{
  margin-top:2px;
  font-size:10px;
  color:#6b7280;
  line-height:1.35;
}
.edm-chat-edit-details{
  display:none;
  align-items:center;
  justify-content:center;
  border:1px solid #d1d5db;
  background:#fff;
  color:#111827;
  border-radius:6px;
  padding:6px 8px;
  font:800 11px Poppins,Arial,sans-serif;
  cursor:pointer;
  white-space:nowrap;
}

/* Mobile refinement: customer details form */
@media(max-width:520px){
  .edm-chat-fields{
    grid-template-columns:1fr;
  }

  .edm-chat-customer-card{
    align-items:flex-start;
  }

  .edm-chat-customer-sub{
    font-size:10px;
    line-height:1.45;
  }

  .edm-chat-edit-details{
    padding:6px 8px;
    font-size:10px;
  }

  .edm-chat-form input,
  .edm-chat-form textarea{
    font-size:13px;
  }

  .edm-chat-form input[name="meter_number"]::placeholder{
    font-size:12px;
  }
}

/* Mobile compact refinement */
@media(max-width:520px){
  .edm-chat-panel{
    bottom:72px;
    height:calc(100vh - 92px);
    max-height:calc(100vh - 92px);
  }

  .edm-chat-head{
    padding:11px 14px;
  }

  .edm-chat-title{
    font-size:14px;
  }

  .edm-chat-sub{
    font-size:10px;
  }

  .edm-chat-agent-status{
    padding:7px 12px;
    font-size:10.5px;
    line-height:1.35;
  }

  .edm-chat-body{
    padding:10px 12px;
  }

  .edm-chat-msg{
    margin-bottom:8px;
    padding:8px 10px;
    font-size:12.5px;
    line-height:1.38;
  }

  .edm-chat-meta{
    font-size:9.5px;
  }

  .edm-chat-form{
    padding:10px 12px;
    gap:7px;
  }

  .edm-chat-customer-card{
    padding:8px 10px;
  }

  .edm-chat-customer-title{
    font-size:11.5px;
  }

  .edm-chat-customer-sub{
    font-size:9.5px;
    line-height:1.35;
  }

  .edm-chat-form input{
    padding:8px 10px;
    min-height:42px;
  }

  .edm-chat-form textarea{
    height:72px;
    min-height:72px;
    padding:9px 10px;
  }

  .edm-chat-form input[type="file"]{
    padding:7px 10px;
    min-height:40px;
  }

  .edm-chat-send{
    padding:9px 12px;
    min-height:42px;
  }

  .edm-chat-end{
    padding:5px 8px;
    font-size:10px;
  }

  .edm-chat-close{
    font-size:20px;
  }
}

/* Strong compact mode for first-time mobile customer details */
@media(max-width:520px){
  .edm-chat-panel{
    bottom:68px !important;
    height:calc(100vh - 88px) !important;
    max-height:calc(100vh - 88px) !important;
  }

  .edm-chat-body{
    padding:8px 10px !important;
  }

  .edm-chat-quick{
    padding:7px 10px !important;
    gap:5px !important;
  }

  .edm-chat-quick button{
    padding:6px 8px !important;
    font-size:11px !important;
  }

  .edm-chat-form{
    padding:8px 10px !important;
    gap:5px !important;
  }

  .edm-chat-customer-card{
    padding:7px 9px !important;
    border-radius:7px !important;
  }

  .edm-chat-customer-title{
    font-size:11px !important;
  }

  .edm-chat-customer-sub{
    font-size:9px !important;
    line-height:1.28 !important;
  }

  .edm-chat-fields{
    gap:5px !important;
  }

  .edm-chat-form input{
    height:36px !important;
    min-height:36px !important;
    padding:6px 9px !important;
    font-size:12px !important;
  }

  .edm-chat-form textarea{
    height:54px !important;
    min-height:54px !important;
    padding:7px 9px !important;
    font-size:12px !important;
  }

  .edm-chat-form input[type="file"]{
    height:36px !important;
    min-height:36px !important;
    padding:5px 9px !important;
    font-size:12px !important;
  }

  .edm-chat-send{
    min-height:38px !important;
    padding:8px 12px !important;
    font-size:12px !important;
  }
}

/* Real compact mode: before customer details are completed */
.edm-chat-panel.details-required .edm-chat-quick{
  display:none !important;
}

@media(max-width:520px){
  .edm-chat-panel.details-required{
    height:auto !important;
    max-height:calc(100vh - 82px) !important;
  }

  .edm-chat-panel.details-required .edm-chat-body{
    display:none !important;
  }

  .edm-chat-panel.details-required .edm-chat-form{
    padding:8px 10px !important;
  }

  .edm-chat-panel.details-required .edm-chat-customer-card{
    margin-bottom:2px !important;
  }

  .edm-chat-panel.details-required .edm-chat-form input{
    height:34px !important;
    min-height:34px !important;
    padding:5px 9px !important;
  }

  .edm-chat-panel.details-required .edm-chat-form textarea{
    height:48px !important;
    min-height:48px !important;
  }

  .edm-chat-panel.details-required .edm-chat-form input[type="file"]{
    height:34px !important;
    min-height:34px !important;
  }

  .edm-chat-panel.details-required .edm-chat-send{
    min-height:36px !important;
  }
}

/* Ticket created card */
.edm-ticket-card{
  margin:10px 0;
  padding:12px 13px;
  border:1px solid #f2531e;
  border-left:4px solid #f2531e;
  background:#fff7ed;
  border-radius:8px;
  color:#111827;
  box-shadow:0 1px 2px rgba(0,0,0,.05);
}
.edm-ticket-card-title{
  font-size:13px;
  font-weight:900;
  margin-bottom:4px;
}
.edm-ticket-card-ref{
  font-size:12px;
  margin-bottom:4px;
}
.edm-ticket-card-note{
  font-size:11px;
  color:#4b5563;
  line-height:1.4;
}
@media(max-width:520px){
  .edm-ticket-card{
    padding:10px 11px;
    margin:8px 0;
  }
}

.edm-chat-window-note{
  padding:7px 12px;
  font-size:10.5px;
  line-height:1.35;
  font-weight:700;
  background:#f9fafb;
  color:#4b5563;
  border-bottom:1px solid #e5e7eb;
}

@media(max-width:520px){
  .edm-chat-window-note{
    padding:6px 10px;
    font-size:9.5px;
    line-height:1.3;
  }
}

/* Customer details cleanup: avoid squeezed two-column fields */
.edm-chat-panel.details-required .edm-chat-fields{
  grid-template-columns:1fr !important;
  gap:7px !important;
}

.edm-chat-panel.details-required .edm-chat-customer-card{
  border-left:4px solid #f2531e !important;
}

.edm-chat-panel.details-required .edm-chat-customer-title{
  color:#111827 !important;
}

.edm-chat-panel.details-required .edm-chat-form input,
.edm-chat-panel.details-required .edm-chat-form textarea{
  width:100% !important;
  box-sizing:border-box !important;
}

.edm-chat-panel.details-required .edm-chat-form input{
  min-height:40px !important;
  height:40px !important;
}

.edm-chat-panel.details-required .edm-chat-form textarea{
  min-height:58px !important;
  height:58px !important;
}

.edm-chat-panel.details-required .edm-chat-send{
  background:#111827 !important;
  color:#fff !important;
}

.edm-chat-panel.details-required .edm-chat-send:hover{
  background:#f2531e !important;
  color:#fff !important;
}

/* Message textarea fix: prevent squeezed message box */
.edm-chat-form textarea[name="message"],
.edm-chat-panel.details-required .edm-chat-form textarea[name="message"]{
  min-height:88px !important;
  height:88px !important;
  line-height:1.45 !important;
  padding:10px 12px !important;
  resize:vertical !important;
  display:block !important;
  color:#111827 !important;
  background:#fff !important;
}

.edm-chat-form textarea[name="message"]::placeholder{
  color:#9ca3af !important;
  opacity:1 !important;
}

@media(max-width:520px){
  .edm-chat-form textarea[name="message"],
  .edm-chat-panel.details-required .edm-chat-form textarea[name="message"]{
    min-height:78px !important;
    height:78px !important;
    padding:9px 10px !important;
    line-height:1.4 !important;
  }
}

/* Final intake form visibility fix:
   keep customer details, message, attachment, and send button visible */
.edm-chat-panel.details-required{
  bottom:18px !important;
  height:auto !important;
  max-height:calc(100vh - 36px) !important;
  overflow:hidden !important;
}

.edm-chat-panel.details-required .edm-chat-head{
  padding:9px 12px !important;
  min-height:auto !important;
}

.edm-chat-panel.details-required .edm-chat-title{
  font-size:13px !important;
  line-height:1.15 !important;
}

.edm-chat-panel.details-required .edm-chat-sub{
  font-size:9px !important;
  line-height:1.15 !important;
  margin-top:1px !important;
}

.edm-chat-panel.details-required .edm-chat-head-actions{
  gap:6px !important;
}

.edm-chat-panel.details-required .edm-chat-end{
  padding:5px 8px !important;
  font-size:10px !important;
}

.edm-chat-panel.details-required .edm-chat-close{
  font-size:18px !important;
}

.edm-chat-panel.details-required .edm-chat-agent-status{
  padding:6px 10px !important;
  font-size:10px !important;
  line-height:1.25 !important;
}

/* Hide this only during first-time intake to save space */
.edm-chat-panel.details-required .edm-chat-window-note{
  display:none !important;
}

.edm-chat-panel.details-required .edm-chat-body,
.edm-chat-panel.details-required .edm-chat-quick{
  display:none !important;
}

.edm-chat-panel.details-required .edm-chat-form{
  padding:8px 10px !important;
  gap:5px !important;
  overflow:visible !important;
}

.edm-chat-panel.details-required .edm-chat-customer-card{
  padding:7px 9px !important;
  margin:0 0 4px 0 !important;
  border-left:4px solid #f2531e !important;
  border-radius:6px !important;
}

.edm-chat-panel.details-required .edm-chat-customer-title{
  font-size:11px !important;
  line-height:1.15 !important;
}

.edm-chat-panel.details-required .edm-chat-customer-sub{
  font-size:9px !important;
  line-height:1.2 !important;
  margin-top:2px !important;
}

.edm-chat-panel.details-required .edm-chat-fields{
  grid-template-columns:1fr !important;
  gap:4px !important;
}

.edm-chat-panel.details-required .edm-chat-form input{
  height:31px !important;
  min-height:31px !important;
  padding:4px 8px !important;
  font-size:11px !important;
  line-height:1.2 !important;
}

.edm-chat-panel.details-required .edm-chat-form input::placeholder{
  font-size:11px !important;
}

.edm-chat-panel.details-required .edm-chat-form textarea[name="message"]{
  height:52px !important;
  min-height:52px !important;
  max-height:52px !important;
  padding:6px 8px !important;
  font-size:11px !important;
  line-height:1.25 !important;
  resize:none !important;
  color:#111827 !important;
  background:#fff !important;
}

.edm-chat-panel.details-required .edm-chat-form textarea[name="message"]::placeholder{
  color:#9ca3af !important;
  opacity:1 !important;
}

.edm-chat-panel.details-required .edm-chat-form input[type="file"]{
  height:31px !important;
  min-height:31px !important;
  padding:3px 8px !important;
  font-size:11px !important;
  line-height:1.2 !important;
}

.edm-chat-panel.details-required .edm-chat-send{
  height:35px !important;
  min-height:35px !important;
  padding:6px 10px !important;
  font-size:11px !important;
  line-height:1.2 !important;
  background:#111827 !important;
  color:#fff !important;
  border-radius:4px !important;
}

/* On very small phones, make it even tighter */
@media(max-width:520px){
  .edm-chat-panel.details-required{
    right:8px !important;
    left:8px !important;
    bottom:12px !important;
    max-height:calc(100vh - 24px) !important;
  }

  .edm-chat-panel.details-required .edm-chat-agent-status{
    padding:5px 9px !important;
    font-size:9.5px !important;
  }

  .edm-chat-panel.details-required .edm-chat-customer-card{
    padding:6px 8px !important;
  }

  .edm-chat-panel.details-required .edm-chat-form{
    padding:7px 9px !important;
  }

  .edm-chat-panel.details-required .edm-chat-form input{
    height:30px !important;
    min-height:30px !important;
  }

  .edm-chat-panel.details-required .edm-chat-form textarea[name="message"]{
    height:48px !important;
    min-height:48px !important;
    max-height:48px !important;
  }

  .edm-chat-panel.details-required .edm-chat-form input[type="file"]{
    height:30px !important;
    min-height:30px !important;
  }

  .edm-chat-panel.details-required .edm-chat-send{
    height:34px !important;
    min-height:34px !important;
  }
}

/* Conversation area improvement: give message exchange more breathing room */
.edm-chat-panel.open:not(.details-required){
  height:calc(100vh - 56px) !important;
  max-height:720px !important;
  bottom:22px !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-body{
  flex:1 1 auto !important;
  min-height:340px !important;
  max-height:none !important;
  overflow-y:auto !important;
  padding:14px !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-msg{
  font-size:13px !important;
  line-height:1.45 !important;
}

/* Keep the message form compact so the conversation gets more space */
.edm-chat-panel.open:not(.details-required) .edm-chat-form{
  padding:10px 12px !important;
  gap:7px !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-form textarea[name="message"]{
  min-height:62px !important;
  height:62px !important;
  max-height:90px !important;
}

/* Mobile/tablet handling */
@media(max-width:520px){
  .edm-chat-panel.open:not(.details-required){
    right:8px !important;
    left:8px !important;
    bottom:10px !important;
    height:calc(100vh - 22px) !important;
    max-height:calc(100vh - 22px) !important;
  }

  .edm-chat-panel.open:not(.details-required) .edm-chat-body{
    min-height:300px !important;
    padding:10px !important;
  }

  .edm-chat-panel.open:not(.details-required) .edm-chat-form textarea[name="message"]{
    min-height:58px !important;
    height:58px !important;
  }
}

/* Keep send controls visible: only conversation area must scroll */
.edm-chat-panel.open:not(.details-required){
  display:flex !important;
  flex-direction:column !important;
  overflow:hidden !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-head,
.edm-chat-panel.open:not(.details-required) .edm-chat-agent-status,
.edm-chat-panel.open:not(.details-required) .edm-chat-window-note,
.edm-chat-panel.open:not(.details-required) .edm-chat-quick,
.edm-chat-panel.open:not(.details-required) .edm-chat-form{
  flex:0 0 auto !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-body{
  flex:1 1 auto !important;
  min-height:0 !important;
  overflow-y:auto !important;
  max-height:none !important;
}

/* Make the active chat form compact enough to always show file + send */
.edm-chat-panel.open:not(.details-required) .edm-chat-form{
  padding:8px 10px !important;
  gap:6px !important;
  border-top:1px solid #e5e7eb !important;
  background:#fff !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-customer-card{
  padding:7px 9px !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-form textarea[name="message"]{
  min-height:48px !important;
  height:48px !important;
  max-height:48px !important;
  resize:none !important;
  padding:7px 9px !important;
  font-size:12px !important;
  line-height:1.3 !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-form input[type="file"]{
  height:32px !important;
  min-height:32px !important;
  padding:4px 8px !important;
  font-size:11px !important;
}

.edm-chat-panel.open:not(.details-required) .edm-chat-send{
  height:36px !important;
  min-height:36px !important;
  padding:7px 10px !important;
  font-size:12px !important;
  border-radius:4px !important;
  background:#111827 !important;
  color:#fff !important;
}

/* Desktop/tablet: prevent full panel from exceeding screen */
@media(min-width:521px){
  .edm-chat-panel.open:not(.details-required){
    height:calc(100vh - 44px) !important;
    max-height:720px !important;
    bottom:18px !important;
  }
}

/* Phone: keep send button visible above bottom */
@media(max-width:520px){
  .edm-chat-panel.open:not(.details-required){
    height:calc(100vh - 20px) !important;
    max-height:calc(100vh - 20px) !important;
    bottom:10px !important;
  }

  .edm-chat-panel.open:not(.details-required) .edm-chat-body{
    min-height:0 !important;
  }

  .edm-chat-panel.open:not(.details-required) .edm-chat-form{
    padding:7px 9px !important;
  }

  .edm-chat-panel.open:not(.details-required) .edm-chat-form textarea[name="message"]{
    height:44px !important;
    min-height:44px !important;
    max-height:44px !important;
  }

  .edm-chat-panel.open:not(.details-required) .edm-chat-send{
    height:34px !important;
    min-height:34px !important;
  }
}

/* Softer chat conversation colours */
.edm-chat-msg.customer{
  background:#fff3ed !important;
  color:#111827 !important;
  border:1px solid #ffd8c8 !important;
  margin-left:auto !important;
  font-weight:600 !important;
}

.edm-chat-msg.agent{
  background:#eef4ff !important;
  color:#111827 !important;
  border:1px solid #cfe0ff !important;
  margin-left:auto !important;
}

.edm-chat-msg.bot{
  background:#ffffff !important;
  color:#111827 !important;
  border:1px solid #e5e7eb !important;
}

.edm-chat-msg.system{
  background:#f3f4f6 !important;
  color:#374151 !important;
  border:1px solid #e5e7eb !important;
}

.edm-chat-msg.customer .edm-chat-meta{
  color:#9a3412 !important;
}

.edm-chat-msg.agent .edm-chat-meta{
  color:#1d4ed8 !important;
}

.edm-chat-msg.system .edm-chat-meta,
.edm-chat-msg.bot .edm-chat-meta{
  color:#6b7280 !important;
}

/* Floating chat launcher: brand orange with white text */
.edm-chat-launcher{
  background:#f2531e !important;
  color:#ffffff !important;
  border:1px solid #f2531e !important;
}

.edm-chat-launcher:hover{
  background:#d94718 !important;
  color:#ffffff !important;
}

/* Brand orange background must always use white text */
.edm-chat-launcher,
.edm-chat-send:hover,
.edm-ticket-card .edm-ticket-card-ref strong{
  color:#ffffff !important;
}

.edm-chat-launcher{
  background:#f2531e !important;
  border-color:#f2531e !important;
}

.edm-chat-launcher:hover{
  background:#d94718 !important;
  color:#ffffff !important;
}

/* Public chatbot backdrop + page scroll lock */
body.edm-chat-lock-scroll{
  overflow:hidden !important;
  touch-action:none;
}

.edm-chat-backdrop{
  position:fixed;
  inset:0;
  z-index:9997;
  background:rgba(15,23,42,.38);
  backdrop-filter:blur(3px);
  -webkit-backdrop-filter:blur(3px);
  display:none;
}

.edm-chat-backdrop.open{
  display:block;
}

/* Ensure chat sits above backdrop */
.edm-chat-panel{
  z-index:9999 !important;
}

.edm-chat-launcher{
  z-index:9998 !important;
}

/* When chat is open, only the chat content should scroll */
.edm-chat-panel.open{
  overscroll-behavior:contain;
}

.edm-chat-panel.open .edm-chat-body{
  overscroll-behavior:contain;
}

/* iPhone/iOS fix: prevent automatic zoom when typing in chat fields */
@media(max-width:768px){
  .edm-chat-form input,
  .edm-chat-form textarea,
  .edm-chat-form select,
  .edm-chat-form button,
  .edm-chat-form input[type="file"],
  .edm-chat-panel input,
  .edm-chat-panel textarea,
  .edm-chat-panel select,
  .edm-chat-panel button{
    font-size:16px !important;
  }

  .edm-chat-form textarea[name="message"],
  .edm-chat-panel.details-required .edm-chat-form textarea[name="message"],
  .edm-chat-panel.open:not(.details-required) .edm-chat-form textarea[name="message"]{
    font-size:16px !important;
    line-height:1.35 !important;
  }

  .edm-chat-form input::placeholder,
  .edm-chat-form textarea::placeholder{
    font-size:16px !important;
  }
}

/* iPhone safe-area fix: prevent chat header from sitting under browser UI */
@media(max-width:768px){
  .edm-chat-panel.open{
    top:calc(env(safe-area-inset-top, 0px) + 14px) !important;
    bottom:calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
    height:auto !important;
    max-height:none !important;
  }

  .edm-chat-panel.open:not(.details-required){
    top:calc(env(safe-area-inset-top, 0px) + 14px) !important;
    bottom:calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
    height:auto !important;
    max-height:none !important;
  }

  .edm-chat-panel.details-required{
    top:calc(env(safe-area-inset-top, 0px) + 14px) !important;
    bottom:calc(env(safe-area-inset-bottom, 0px) + 12px) !important;
    height:auto !important;
    max-height:none !important;
  }

  .edm-chat-head{
    flex-shrink:0 !important;
  }

  .edm-chat-body{
    min-height:0 !important;
  }
}

/* Public chat conversation alignment:
   Customer on right, support/bot/system on left */
.edm-chat-body{
  display:flex !important;
  flex-direction:column !important;
}

.edm-chat-msg{
  width:auto !important;
  max-width:78% !important;
  clear:both !important;
}

/* Customer/public user message */
.edm-chat-msg.customer{
  align-self:flex-end !important;
  margin-left:auto !important;
  margin-right:0 !important;
  background:#fff3ed !important;
  color:#111827 !important;
  border:1px solid #ffd8c8 !important;
  border-radius:12px 12px 4px 12px !important;
}

/* Agent/support message */
.edm-chat-msg.agent{
  align-self:flex-start !important;
  margin-left:0 !important;
  margin-right:auto !important;
  background:#eef4ff !important;
  color:#111827 !important;
  border:1px solid #cfe0ff !important;
  border-radius:12px 12px 12px 4px !important;
}

/* Bot/system messages */
.edm-chat-msg.bot,
.edm-chat-msg.system{
  align-self:flex-start !important;
  margin-left:0 !important;
  margin-right:auto !important;
  background:#ffffff !important;
  color:#111827 !important;
  border:1px solid #e5e7eb !important;
  border-radius:12px 12px 12px 4px !important;
}

.edm-chat-msg.system{
  background:#f3f4f6 !important;
  color:#374151 !important;
}

.edm-chat-msg.customer .edm-chat-meta{
  color:#9a3412 !important;
}

.edm-chat-msg.agent .edm-chat-meta{
  color:#1d4ed8 !important;
}

.edm-chat-msg.bot .edm-chat-meta,
.edm-chat-msg.system .edm-chat-meta{
  color:#6b7280 !important;
}

@media(max-width:520px){
  .edm-chat-msg{
    max-width:86% !important;
  }
}
