[data-forge-chat-theme] {
  --forge-chat-fill: #ffadc7;
  --forge-chat-hover: #ffcfdf;
  --forge-chat-ink: #2a1327;
  --forge-chat-header: #24192d;
}

[data-forge-chat-theme="mappulse"] {
  --forge-chat-fill: #61d5ff;
  --forge-chat-hover: #a7eaff;
  --forge-chat-ink: #071e30;
  --forge-chat-header: #0c1b2b;
}

[data-forge-chat-theme="voidpulse"] {
  --forge-chat-fill: #f8d181;
  --forge-chat-hover: #fff0ae;
  --forge-chat-ink: #2d1a10;
  --forge-chat-header: #21122e;
}

[data-forge-chat-theme="riftpulse"] {
  --forge-chat-fill: #8ce4cf;
  --forge-chat-hover: #baf8e8;
  --forge-chat-ink: #082024;
  --forge-chat-header: #0e2629;
}

[data-forge-chat-theme="project-04"] {
  --forge-chat-fill: #e0c0f6;
  --forge-chat-hover: #f1d9ff;
  --forge-chat-ink: #25172f;
  --forge-chat-header: #21192b;
}

.forge-live-chat {
  position: fixed;
  inset-inline-end: max(1rem, env(safe-area-inset-right));
  inset-block-end: max(1rem, env(safe-area-inset-bottom));
  z-index: 60;
  box-sizing: border-box;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1rem;
  color: var(--forge-chat-ink);
  background: var(--forge-chat-fill);
  border: 1px solid var(--forge-chat-hover);
  border-radius: 2rem;
  box-shadow: 0 .25rem 1.1rem #0008;
  font: 700 .91rem/1.2 system-ui, sans-serif;
  text-decoration: none;
}
.forge-live-chat:hover { background: var(--forge-chat-hover); }
.forge-live-chat:focus-visible { outline: 2px solid var(--forge-chat-hover); outline-offset: 4px; }
.forge-live-chat:visited, .map-guide a.forge-live-chat { color: var(--forge-chat-ink); }
body:has(dialog[open], [aria-modal="true"]:not([hidden])) .forge-live-chat { display: none; }

.forge-live-chat-panel {
  --forge-chat-paper: color-mix(in srgb, var(--forge-chat-fill) 4%, var(--forge-chat-header));
  --forge-chat-surface: color-mix(in srgb, var(--forge-chat-fill) 9%, var(--forge-chat-header));
  --forge-chat-raised: color-mix(in srgb, var(--forge-chat-fill) 15%, var(--forge-chat-header));
  --forge-chat-rule: color-mix(in srgb, var(--forge-chat-fill) 30%, var(--forge-chat-header));
  position: fixed;
  inset: auto;
  inset-inline-end: max(1rem, env(safe-area-inset-right));
  inset-block-end: max(1rem, env(safe-area-inset-bottom));
  box-sizing: border-box;
  width: min(24rem, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: 0;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--forge-chat-fill) 40%, var(--forge-chat-header));
  border-radius: 1.15rem;
  overflow: hidden;
  color: #f2f7fb;
  background: var(--forge-chat-paper);
  box-shadow: 0 1rem 3.5rem #0007;
}

.forge-live-chat-panel:not([open]) { display: none; }

.forge-live-chat-panel[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.forge-live-chat-panel[data-view="chat"] {
  height: 35rem;
}

.forge-live-chat-panel [hidden] { display: none; }
.forge-live-chat-panel::backdrop { background: #040b1333; }

.forge-live-chat-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  padding: .35rem .5rem .35rem 1.05rem;
  background: var(--forge-chat-header);
  color: var(--forge-chat-fill);
}

.forge-live-chat-header h2 {
  flex: 1;
  margin: 0;
  color: inherit;
  font: 700 1rem/1.3 system-ui, sans-serif;
}

.forge-live-chat-header form { margin: 0; }

.forge-live-chat-header button {
  border: 0;
  border-radius: .6rem;
  width: 2.75rem;
  height: 2.75rem;
  flex: none;
  padding: 0;
  color: inherit;
  background: transparent;
  font: 400 1.6rem/1 system-ui, sans-serif;
  cursor: pointer;
}

.forge-live-chat-header button:hover { background: #ffffff20; }
.forge-live-chat-header button:focus-visible { outline: 2px solid var(--forge-chat-fill); outline-offset: -2px; }

.forge-live-chat-topics {
  overflow: auto;
  min-height: 0;
  padding: 1.25rem;
  background: var(--forge-chat-paper);
  color: inherit;
  font: 500 .93rem/1.45 system-ui, sans-serif;
}

.forge-live-chat-topics h3 {
  margin: 0 0 .85rem;
  color: inherit;
  font: 700 1.03rem/1.35 system-ui, sans-serif;
}

.forge-live-chat-panel .forge-live-chat-hint {
  margin: .75rem 0 0;
  color: color-mix(in srgb, #f2f7fb, var(--forge-chat-paper) 18%);
  font-size: .81rem;
}

.forge-live-chat-actions {
  display: grid;
  gap: .5rem;
}

.forge-live-chat-panel .forge-live-chat-actions :is(a, button) {
  display: flex;
  box-sizing: border-box;
  align-items: center;
  gap: .5rem;
  justify-content: space-between;
  min-height: 2.65rem;
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--forge-chat-rule);
  border-radius: .65rem;
  background: var(--forge-chat-surface);
  color: inherit;
  font: 650 .9rem/1.35 system-ui, sans-serif;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.forge-live-chat-panel .forge-live-chat-actions :is(a, button)::after {
  content: '›' / '';
  flex: none;
}

.forge-live-chat-panel .forge-live-chat-actions :is(a, button):hover { background: var(--forge-chat-raised); }
.forge-live-chat-panel .forge-live-chat-actions [data-chat-open="chat"] {
  border-color: var(--forge-chat-fill);
  background: var(--forge-chat-fill);
  color: var(--forge-chat-ink);
}
.forge-live-chat-panel .forge-live-chat-actions [data-chat-open="chat"]:hover {
  background: var(--forge-chat-hover);
}
.forge-live-chat-panel .forge-live-chat-actions :is(a, button):focus-visible {
  outline: 2px solid var(--forge-chat-fill);
  outline-offset: 2px;
}

.forge-live-chat-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: var(--forge-chat-header);
}

.forge-live-chat-credit {
  padding: .45rem .75rem;
  border-top: 1px solid var(--forge-chat-rule);
  background: var(--forge-chat-paper);
  font: 500 .75rem/1.3 system-ui, sans-serif;
  text-align: center;
}

.forge-live-chat-panel .forge-live-chat-credit a {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--forge-chat-fill);
  text-decoration: none;
}

.forge-live-chat-alternate {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0 .9rem;
  margin-block-end: .2rem;
}
.forge-live-chat-panel .forge-live-chat-alternate a {
  min-height: 2rem;
  text-decoration: underline;
  text-underline-offset: .15em;
}
.forge-live-chat-panel .forge-live-chat-credit a:hover {
  text-decoration: underline;
  text-underline-offset: .15em;
}

.forge-live-chat-credit a:focus-visible {
  outline: 2px solid var(--forge-chat-fill);
  outline-offset: 3px;
}

.forge-live-chat-credit img {
  display: block;
  width: 1rem;
  height: 1rem;
}
