.qg-floating-chat[hidden],
.qg-floating-chat [hidden] { display: none !important; }

.qg-floating-chat {
  position: fixed;
  z-index: 1060;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: min(380px, calc(100vw - 24px));
  color: #e2e8f0;
  font-family: var(--qg-font-sans, Inter, system-ui, sans-serif);
}

.qg-floating-chat button,
.qg-floating-chat input { font: inherit; }

.qg-floating-chat-bar {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 52px;
  padding: 7px 12px;
  color: #f8fafc;
  border: 1px solid rgba(94, 234, 212, .42);
  border-radius: 16px;
  background: linear-gradient(110deg, rgba(15, 23, 42, .98), rgba(15, 118, 110, .96));
  box-shadow: 0 16px 42px rgba(2, 6, 23, .38);
  text-align: left;
  cursor: pointer;
}

.qg-floating-chat-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  color: #042f2e;
  background: #5eead4;
}

.qg-floating-chat-bar-copy { display: grid; min-width: 0; gap: 1px; }
.qg-floating-chat-bar-copy strong { color: #fff; font-size: .82rem; line-height: 1.3; }
.qg-floating-chat-bar-copy > span {
  overflow: hidden;
  color: #ccfbf1;
  font-size: .76rem;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qg-floating-chat-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  color: #fff;
  background: #e11d48;
  font-size: .68rem;
  font-weight: 800;
}

.qg-floating-chat-expand-icon { color: #99f6e4; font-size: .72rem; }
.qg-floating-chat.is-open .qg-floating-chat-bar { display: none; }

.qg-floating-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(150px, 1fr) auto auto auto;
  overflow: hidden;
  width: 100%;
  height: min(560px, calc(100dvh - 112px));
  max-height: 76dvh;
  border: 1px solid rgba(94, 234, 212, .34);
  border-radius: 18px;
  background: rgba(8, 16, 31, .98);
  box-shadow: 0 24px 65px rgba(2, 6, 23, .55);
}

.qg-floating-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px 10px 15px;
  border-bottom: 1px solid rgba(148, 163, 184, .18);
  background: linear-gradient(110deg, rgba(15, 23, 42, .98), rgba(15, 118, 110, .48));
}

.qg-floating-chat-heading { display: grid; gap: 2px; min-width: 0; }
.qg-floating-chat-head span { color: #99f6e4; font-size: .68rem; font-weight: 800; }
.qg-floating-chat-head span i { font-size: .46rem; }
.qg-floating-chat-heading select {
  width: min(190px, 46vw);
  min-height: 32px;
  padding: 4px 28px 4px 8px;
  color: #fff;
  border: 1px solid rgba(94, 234, 212, .32);
  border-radius: 8px;
  background: #10253a;
  font-size: .82rem;
  font-weight: 800;
  cursor: pointer;
}
.qg-floating-chat-heading select:focus-visible {
  outline: 2px solid #5eead4;
  outline-offset: 2px;
}
.qg-floating-chat-head-actions { display: flex; align-items: center; gap: 6px; }
.qg-floating-chat-head-actions a {
  color: #ccfbf1;
  font-size: .72rem;
  font-weight: 700;
  text-decoration: none;
}
.qg-floating-chat-head-actions a:hover { text-decoration: underline; }
.qg-floating-chat-head-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #e2e8f0;
  border: 1px solid rgba(148, 163, 184, .24);
  border-radius: 11px;
  background: rgba(15, 23, 42, .72);
  cursor: pointer;
}

.qg-floating-chat-log {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(2, 6, 23, .56);
}

.qg-floating-chat-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, .17);
  border-radius: 11px;
  background: rgba(30, 41, 59, .76);
}
.qg-floating-chat-entry header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.qg-floating-chat-entry header strong {
  overflow: hidden;
  color: #5eead4;
  font-size: .74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qg-floating-chat-entry time { flex: 0 0 auto; color: #94a3b8; font-size: .64rem; }
.qg-floating-chat-entry p {
  grid-column: 1;
  margin: 0;
  color: #e2e8f0;
  font-size: .79rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.qg-floating-chat-report {
  grid-column: 2;
  grid-row: 2;
  align-self: end;
  padding: 2px 0;
  color: #94a3b8;
  border: 0;
  background: transparent;
  font-size: .62rem;
  cursor: pointer;
}
.qg-floating-chat-report:hover { color: #fca5a5; text-decoration: underline; }
.qg-floating-chat-report:disabled { cursor: default; opacity: .7; }

.qg-floating-chat-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  padding: 24px;
  color: #94a3b8;
  font-size: .8rem;
  text-align: center;
}
.qg-floating-chat-empty i { color: #5eead4; font-size: 1.3rem; }

.qg-floating-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(148, 163, 184, .18);
  background: #0f172a;
}
.qg-floating-chat-form input {
  min-width: 0;
  min-height: 46px;
  padding: 9px 12px;
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 11px;
  outline: none;
  background: #111c30;
  font-size: .84rem;
}
.qg-floating-chat-form input::placeholder { color: #94a3b8; }
.qg-floating-chat-form input:focus { border-color: #5eead4; box-shadow: 0 0 0 3px rgba(45, 212, 191, .13); }
.qg-floating-chat-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 72px;
  min-height: 46px;
  padding: 8px 12px;
  color: #042f2e;
  border: 0;
  border-radius: 11px;
  background: #5eead4;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
}
.qg-floating-chat-form button:disabled { cursor: wait; opacity: .6; }

.qg-floating-chat-status {
  min-height: 0;
  margin: 0;
  padding: 0 12px;
  color: #fca5a5;
  background: #0f172a;
  font-size: .7rem;
}
.qg-floating-chat-status:not(:empty) { padding-bottom: 7px; }
.qg-floating-chat-note {
  margin: 0;
  padding: 7px 12px 9px;
  color: #94a3b8;
  border-top: 1px solid rgba(148, 163, 184, .12);
  background: #0f172a;
  font-size: .65rem;
  line-height: 1.4;
}
.qg-floating-chat-note i { margin-right: 4px; color: #5eead4; }
.qg-visually-hidden {
  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;
}

@media (max-width: 760px) {
  body.qg-floating-chat-enabled { padding-bottom: max(68px, calc(58px + env(safe-area-inset-bottom))); }
  .qg-floating-chat {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(8px, env(safe-area-inset-left));
    width: auto;
  }
  .qg-floating-chat-bar { min-height: 50px; border-radius: 14px; }
  .qg-floating-chat-panel {
    height: min(58dvh, 480px);
    max-height: calc(100dvh - 72px);
    border-radius: 16px;
  }
  .qg-floating-chat-head { min-height: 54px; padding-block: 7px; }
  .qg-floating-chat-heading select { width: min(170px, 42vw); }
  .qg-floating-chat-log { padding: 9px; }
  .qg-floating-chat-form { padding: 8px 9px; }
  .qg-floating-chat-form button { min-width: 48px; padding-inline: 11px; }
  .qg-floating-chat-form button span { display: none; }
}

@media (max-width: 380px) {
  .qg-floating-chat-mark { width: 34px; height: 34px; }
  .qg-floating-chat-bar { grid-template-columns: 36px minmax(0, 1fr) auto auto; padding-inline: 9px; }
  .qg-floating-chat-head-actions a { display: none; }
  .qg-floating-chat-heading select { width: min(180px, 58vw); }
}

@media (prefers-reduced-motion: reduce) {
  .qg-floating-chat * { scroll-behavior: auto !important; }
}

@media print {
  .qg-floating-chat { display: none !important; }
}
