.pifire-ec-root{
  --pif-bg: #0f1419;
  --pif-panel: #1a2332;
  --pif-panel-2: #243044;
  --pif-accent: #e85d04;
  --pif-accent-2: #f48c06;
  --pif-danger: #d00000;
  --pif-text: #f1f5f9;
  --pif-muted: #94a3b8;
  --pif-ok: #2a9d8f;
  --pif-border: #334155;
  --pif-radius: 14px;
  --pif-shadow: 0 16px 48px rgba(0, 0, 0, .55);
  font-family: Segoe UI, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--pif-text);
  box-sizing: border-box;
}
.pifire-ec-root *, .pifire-ec-root *:before, .pifire-ec-root *:after{
  box-sizing: border-box;
}

/* Launcher Button */
.pifire-ec-launcher{
  position: fixed;
  z-index: 2147483000;
  right: 20px;
  bottom: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--pif-accent-2), var(--pif-accent));
  color: #fff;
  box-shadow: var(--pif-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease;
}
.pifire-ec-launcher:hover, .pifire-ec-launcher:focus-visible{
  transform: scale(1.06);
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.pifire-ec-launcher svg{
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* Panel Window */
.pifire-ec-panel{
  position: fixed;
  z-index: 2147483001;
  right: 20px;
  bottom: 92px;
  width: min(440px, calc(100vw - 24px));
  height: min(720px, calc(100vh - 110px));
  background: var(--pif-bg);
  border: 1px solid var(--pif-border);
  border-radius: var(--pif-radius);
  box-shadow: var(--pif-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pifire-ec-panel[hidden]{
  display: none !important;
}

/* Header */
.pifire-ec-header{
  background: var(--pif-panel);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--pif-border);
  flex: none;
}
.pifire-ec-header h2{
  margin: 0;
  font-size: 1rem;
  font-weight: 650;
  flex: 1;
}
.pifire-ec-header .pifire-ec-sub{
  display: block;
  font-size: .72rem;
  font-weight: 400;
  color: var(--pif-muted);
  margin-top: 2px;
}
.pifire-ec-close{
  background: transparent;
  border: none;
  color: var(--pif-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
}
.pifire-ec-close:hover, .pifire-ec-close:focus-visible{
  color: var(--pif-text);
  background: var(--pif-panel-2);
}

/* 911 Emergency Bar */
.pifire-ec-911-bar{
  background: var(--pif-danger);
  color: #fff;
  text-align: center;
  padding: 8px;
  font-weight: 700;
  letter-spacing: .02em;
  text-decoration: none;
  display: block;
  flex: none;
}
.pifire-ec-911-bar:hover{
  filter: brightness(1.08);
}

/* Hidden elements MUST be completely removed from layout */
[hidden], .pifire-ec-gate[hidden], .pifire-ec-body[hidden]{
  display: none !important;
  flex: 0 0 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
}



.pifire-ec-gate{
  position: absolute !important;
  inset: 0 !important;
  z-index: 99999 !important;
  background: var(--pif-bg) !important;
  padding: 20px !important;
  overflow-y: auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 14px !important;
}
.pifire-ec-gate[hidden], [hidden]{
  display: none !important;
}

/* Chat Body - Takes FULL available height! */
.pifire-ec-body{
  flex: 1 1 0% !important;
  height: 100% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  padding: 14px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}

/* Message styling */
.pifire-ec-msg{
  max-width: 100%;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.pifire-ec-msg.user{
  align-self: flex-end;
  background: var(--pif-panel-2);
  width: auto;
  max-width: 90%;
}
.pifire-ec-msg.bot{
  align-self: stretch;
  background: var(--pif-panel);
  border: 1px solid var(--pif-border);
}
.pifire-ec-msg.escalation{
  border: 2px solid var(--pif-danger);
  background: #2a1010;
}
.pifire-ec-msg h3{
  margin: 0 0 8px;
  font-size: 1.02rem;
  color: #fff;
}
.pifire-ec-msg ol, .pifire-ec-msg ul{
  margin: 8px 0;
  padding-left: 1.3rem;
}
.pifire-ec-msg li{
  margin: 5px 0;
  line-height: 1.4;
}
.pifire-ec-footer-note{
  margin-top: 10px;
  font-size: .72rem;
  color: var(--pif-muted);
  border-top: 1px solid var(--pif-border);
  padding-top: 8px;
}
.pifire-ec-meta{
  font-size: .68rem;
  color: var(--pif-muted);
  margin-top: 4px;
}
.pifire-ec-checklist{
  list-style: none;
  padding: 0;
  margin: 8px 0;
}
.pifire-ec-checklist li{
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 6px 0;
  font-size: .9rem;
}
.pifire-ec-checklist input{
  margin-top: 3px;
  accent-color: var(--pif-ok);
}

/* Buttons */
.pifire-ec-btn{
  border: none;
  border-radius: 10px;
  padding: 12px 14px;
  font-weight: 650;
  cursor: pointer;
  font-size: .95rem;
}
.pifire-ec-btn.primary{
  background: var(--pif-accent);
  color: #fff;
}
.pifire-ec-btn.secondary{
  background: var(--pif-panel-2);
  color: var(--pif-text);
  border: 1px solid var(--pif-border);
}
.pifire-ec-btn:focus-visible{
  outline: 2px solid var(--pif-accent-2);
  outline-offset: 2px;
}

/* Quick Action Chips */
.pifire-ec-quick{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px 10px;
  flex: none;
}
.pifire-ec-chip{
  background: var(--pif-panel-2);
  border: 1px solid var(--pif-border);
  color: var(--pif-text);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: .75rem;
  cursor: pointer;
  transition: all .12s;
}
.pifire-ec-chip:hover, .pifire-ec-chip:focus-visible{
  border-color: var(--pif-accent-2);
  background: var(--pif-border);
}

/* Composer / Input Bar */
.pifire-ec-composer{
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--pif-border);
  background: var(--pif-panel);
  flex: none;
}
.pifire-ec-composer input{
  flex: 1;
  background: var(--pif-bg);
  border: 1px solid var(--pif-border);
  border-radius: 10px;
  color: var(--pif-text);
  padding: 10px 12px;
  font-size: .95rem;
}
.pifire-ec-composer input:focus{
  outline: 2px solid var(--pif-accent);
  border-color: transparent;
}
.pifire-ec-composer button{
  background: var(--pif-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 18px;
  font-weight: 650;
  cursor: pointer;
  transition: opacity .15s;
}
.pifire-ec-composer button:disabled{
  opacity: .5;
  cursor: not-allowed;
}

@media(max-width: 480px){
  .pifire-ec-panel{
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
  .pifire-ec-launcher{
    right: 16px;
    bottom: 16px;
  }
}