:root {
  --nswiki-agent-panel-width: 440px;
  --nswiki-agent-drawer-height: min(78dvh, 640px);
  --nswiki-agent-motion-in: 400ms;
  --nswiki-agent-motion-out: 250ms;
  --nswiki-agent-ease-in: cubic-bezier(0.4, 0, 0.2, 1);
  --nswiki-agent-ease-out: cubic-bezier(0.8, 0, 0.6, 1);
}

.__nswiki-root,
.__nswiki-root * {
  box-sizing: border-box;
  letter-spacing: 0;
}

.__nswiki-root {
  color: var(--md-default-fg-color, #202124);
  font-family: var(--md-text-font-family, system-ui, sans-serif);
}

.__nswiki-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--md-default-fg-color, #202124);
  color: var(--md-default-bg-color, #fff);
  box-shadow: 0 16px 48px -18px rgba(15, 23, 42, 0.45);
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 160ms ease, transform 160ms ease, background-color 160ms ease;
}

.__nswiki-btn:hover {
  background: var(--md-default-fg-color--light, #414141);
  transform: translateY(-1px);
}

.__nswiki-btn:focus-visible,
.__nswiki-icon-btn:focus-visible,
.__nswiki-start-action:focus-visible,
.__nswiki-send:focus-visible {
  outline: 2px solid var(--md-accent-fg-color, #526cfe);
  outline-offset: 2px;
}

.__nswiki-root.is-open > .__nswiki-btn {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.__nswiki-panel {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 9999;
  display: flex;
  width: var(--nswiki-agent-panel-width);
  max-width: 100vw;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--md-default-fg-color--lightest, #e5e5e5);
  background: var(--md-default-bg-color, #fff);
  box-shadow: -18px 0 48px -36px rgba(15, 23, 42, 0.38);
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition:
    transform var(--nswiki-agent-motion-out) var(--nswiki-agent-ease-out),
    visibility 0s linear var(--nswiki-agent-motion-out);
  will-change: transform;
}

.__nswiki-panel.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
  transition:
    transform var(--nswiki-agent-motion-in) var(--nswiki-agent-ease-in),
    visibility 0s linear 0s;
}

.__nswiki-panel > .__nswiki-header > *,
.__nswiki-panel > .__nswiki-content,
.__nswiki-panel > .__nswiki-composer {
  opacity: 0;
  transform: translateX(12px);
  transition:
    opacity 120ms linear,
    transform var(--nswiki-agent-motion-out) var(--nswiki-agent-ease-out);
}

.__nswiki-panel.open > .__nswiki-header > *,
.__nswiki-panel.open > .__nswiki-content,
.__nswiki-panel.open > .__nswiki-composer {
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity 180ms 60ms linear,
    transform var(--nswiki-agent-motion-in) 30ms var(--nswiki-agent-ease-in);
}

.__nswiki-header {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 16px;
  flex: none;
  border-bottom: 1px solid var(--md-default-fg-color--lightest, #e5e5e5);
  background: var(--md-default-bg-color, #fff);
}

.__nswiki-title {
  margin: 0;
  color: var(--md-default-fg-color, #202124);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
}

.__nswiki-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.__nswiki-icon-btn,
.__nswiki-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  border: 0;
  color: var(--md-default-fg-color--light, #6d6d6d);
  cursor: pointer;
}

.__nswiki-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: transparent;
  transition: color 150ms ease, background-color 150ms ease;
}

.__nswiki-icon-btn:hover {
  background: var(--md-code-bg-color, #f5f5f5);
  color: var(--md-default-fg-color, #202124);
}

.__nswiki-icon-btn svg,
.__nswiki-start-icon svg,
.__nswiki-send svg {
  width: 18px;
  height: 18px;
}

.__nswiki-content {
  position: relative;
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
}

.__nswiki-msgs {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 24px 20px;
  color: var(--md-default-fg-color, #202124);
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.__nswiki-welcome {
  width: 100%;
  margin: auto 0 0;
  padding: 32px 0 12px;
}

.__nswiki-welcome[hidden] {
  display: none;
}

.__nswiki-welcome h3 {
  margin: 0 0 22px;
  color: var(--md-default-fg-color, #202124);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.__nswiki-start-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.__nswiki-start-action {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 8px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--md-default-fg-color--light, #6d6d6d);
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  text-align: left;
  transition: color 150ms ease, background-color 150ms ease;
}

.__nswiki-start-action:hover {
  background: var(--md-code-bg-color, #f5f5f5);
  color: var(--md-default-fg-color, #202124);
}

.__nswiki-start-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

.__nswiki-msg {
  max-width: 100%;
  color: var(--md-default-fg-color, #202124);
  font-size: 14px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.__nswiki-msg.user {
  align-self: flex-end;
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: var(--md-code-bg-color, #f2f2f2);
}

.__nswiki-msg.bot {
  align-self: stretch;
  padding: 0 2px;
}

.__nswiki-msg.bot p {
  margin: 0 0 0.75em;
}

.__nswiki-msg.bot p:last-child {
  margin-bottom: 0;
}

.__nswiki-msg.bot h1,
.__nswiki-msg.bot h2,
.__nswiki-msg.bot h3,
.__nswiki-msg.bot h4,
.__nswiki-msg.bot h5,
.__nswiki-msg.bot h6 {
  margin: 1em 0 0.45em;
  font-weight: 700;
  line-height: 1.3;
}

.__nswiki-msg.bot h1 { font-size: 1.25em; }
.__nswiki-msg.bot h2 { font-size: 1.16em; }
.__nswiki-msg.bot h3 { font-size: 1.08em; }
.__nswiki-msg.bot h4,
.__nswiki-msg.bot h5,
.__nswiki-msg.bot h6 { font-size: 1em; }

.__nswiki-msg.bot ul,
.__nswiki-msg.bot ol {
  margin: 0.65em 0;
  padding-left: 1.6em;
}

.__nswiki-msg.bot li {
  margin: 0.25em 0;
}

.__nswiki-msg.bot blockquote {
  margin: 0.8em 0;
  padding: 4px 0 4px 12px;
  border-left: 3px solid var(--md-primary-fg-color, #4051b5);
  color: var(--md-default-fg-color--light, #6d6d6d);
}

.__nswiki-msg.bot hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--md-default-fg-color--lightest, #e5e5e5);
}

.__nswiki-msg.bot code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--md-code-bg-color, #f5f5f5);
  font-family: var(--md-code-font-family, ui-monospace, monospace);
  font-size: 0.9em;
}

.__nswiki-msg.bot pre {
  margin: 0.8em 0;
  padding: 12px;
  overflow-x: auto;
  border-radius: 6px;
  background: var(--md-code-bg-color, #f5f5f5);
  font-size: 0.88em;
}

.__nswiki-msg.bot pre code {
  padding: 0;
  background: transparent;
  font-size: inherit;
}

.__nswiki-msg.bot img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0.8em auto;
  border-radius: 6px;
}

.__nswiki-msg.bot table {
  display: block;
  width: 100%;
  margin: 0.8em 0;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 0.92em;
}

.__nswiki-msg.bot th,
.__nswiki-msg.bot td {
  padding: 7px 9px;
  border: 1px solid var(--md-default-fg-color--lightest, #e5e5e5);
  text-align: left;
}

.__nswiki-msg.bot th {
  background: var(--md-code-bg-color, #f5f5f5);
  font-weight: 700;
}

.__nswiki-msg.bot a,
.__nswiki-sources a {
  color: var(--md-typeset-a-color, #4051b5);
  text-decoration: none;
}

.__nswiki-msg.bot a:hover,
.__nswiki-sources a:hover {
  text-decoration: underline;
}

.__nswiki-sources {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--md-default-fg-color--lightest, #e5e5e5);
  color: var(--md-default-fg-color--light, #6d6d6d);
  font-size: 12px;
  line-height: 1.6;
}

.__nswiki-thinking {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  color: var(--md-default-fg-color--light, #6d6d6d);
}

.__nswiki-thinking span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: __nswiki-thinking 1.1s ease-in-out infinite;
}

.__nswiki-thinking span:nth-child(2) { animation-delay: 120ms; }
.__nswiki-thinking span:nth-child(3) { animation-delay: 240ms; }

@keyframes __nswiki-thinking {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.__nswiki-composer {
  position: relative;
  z-index: 2;
  flex: none;
  padding: 10px 16px max(16px, env(safe-area-inset-bottom));
  background: var(--md-default-bg-color, #fff);
}

.__nswiki-composer-shell {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 52px;
  padding: 7px 8px 7px 16px;
  border: 1px solid var(--md-default-fg-color--lightest, #dedede);
  border-radius: 24px;
  background: var(--md-code-bg-color, #f5f5f5);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.__nswiki-composer-shell:focus-within {
  border-color: var(--md-default-fg-color--light, #6d6d6d);
  box-shadow: 0 0 0 1px var(--md-default-fg-color--lightest, #dedede);
}

.__nswiki-composer textarea {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  max-height: 120px;
  padding: 8px 0 6px;
  overflow-y: auto;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--md-default-fg-color, #202124);
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  scrollbar-width: none;
  -webkit-tap-highlight-color: transparent;
}

.__nswiki-composer textarea:focus,
.__nswiki-composer textarea:focus-visible,
.__nswiki-composer textarea.focus-visible {
  outline: 0;
}

.__nswiki-composer textarea::-webkit-scrollbar {
  display: none;
}

.__nswiki-composer textarea::placeholder {
  color: var(--md-default-fg-color--lighter, #909090);
  opacity: 1;
}

.__nswiki-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--md-default-fg-color, #202124);
  color: var(--md-default-bg-color, #fff);
  transition: opacity 150ms ease, transform 150ms ease;
}

.__nswiki-send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.__nswiki-send:disabled {
  opacity: 0.28;
  cursor: default;
}

.__nswiki-count {
  display: block;
  height: 12px;
  margin: 4px 10px 0 0;
  color: var(--md-default-fg-color--light, #6d6d6d);
  font-size: 10px;
  line-height: 12px;
  text-align: right;
  opacity: 0;
}

.__nswiki-count.warn,
.__nswiki-count.over {
  opacity: 1;
}

.__nswiki-count.warn { color: #ad6800; }
.__nswiki-count.over { color: #c62828; font-weight: 700; }

[data-md-color-scheme="slate"] .__nswiki-btn,
[data-md-color-scheme="slate"] .__nswiki-send {
  background: #f5f5f5;
  color: #181818;
}

[data-md-color-scheme="slate"] .__nswiki-btn:hover {
  background: #dedede;
}

.md-header,
.md-container {
  min-width: 0;
  margin-inline-end: 0;
  transition:
    margin-inline-end var(--nswiki-agent-motion-out) var(--nswiki-agent-ease-out),
    transform var(--nswiki-agent-motion-out) var(--nswiki-agent-ease-out);
}

@media screen and (min-width: 768px) {
  .md-sidebar--secondary {
    min-width: 0;
    opacity: 1;
    visibility: visible;
    transition:
      width var(--nswiki-agent-motion-out) var(--nswiki-agent-ease-out),
      opacity 160ms linear 70ms,
      visibility 0s linear 0s;
  }

  body.__nswiki-chat-open .md-sidebar--secondary {
    width: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      width var(--nswiki-agent-motion-in) var(--nswiki-agent-ease-in),
      opacity 180ms linear,
      visibility 0s linear var(--nswiki-agent-motion-in);
  }

  body.__nswiki-chat-open .md-header,
  body.__nswiki-chat-open .md-container {
    margin-inline-end: var(--nswiki-agent-panel-width);
    transition-duration: var(--nswiki-agent-motion-in);
    transition-timing-function: var(--nswiki-agent-ease-in);
  }

  body.__nswiki-chat-open .md-search {
    display: none;
  }
}

@media screen and (max-width: 767.98px) {
  .__nswiki-btn {
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
  }

  .__nswiki-panel {
    inset: auto 0 0;
    width: 100%;
    height: var(--nswiki-agent-drawer-height);
    max-height: calc(100dvh - 12px);
    border: 1px solid var(--md-default-fg-color--lightest, #e5e5e5);
    border-bottom: 0;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -16px 44px -30px rgba(15, 23, 42, 0.5);
    transform: translateY(100%);
  }

  .__nswiki-panel.open {
    transform: translateY(0);
  }

  .__nswiki-panel > .__nswiki-header > *,
  .__nswiki-panel > .__nswiki-content,
  .__nswiki-panel > .__nswiki-composer {
    transform: translateY(10px);
  }

  .__nswiki-panel.open > .__nswiki-header > *,
  .__nswiki-panel.open > .__nswiki-content,
  .__nswiki-panel.open > .__nswiki-composer {
    transform: translateY(0);
  }

  body.__nswiki-chat-open .md-container {
    transform: translateY(calc(-1 * var(--nswiki-agent-drawer-height)));
    transition-duration: var(--nswiki-agent-motion-in);
    transition-timing-function: var(--nswiki-agent-ease-in);
  }

  .__nswiki-header {
    height: 58px;
    padding: 0 14px;
  }

  .__nswiki-msgs {
    gap: 16px;
    padding: 20px 16px;
  }

  .__nswiki-welcome {
    padding-bottom: 6px;
  }

  .__nswiki-welcome h3 {
    margin-bottom: 18px;
    font-size: 24px;
  }

  .__nswiki-start-action {
    min-height: 42px;
    font-size: 14px;
  }

  .__nswiki-msg {
    font-size: 13.5px;
  }

  .__nswiki-composer {
    padding: 8px 12px max(12px, env(safe-area-inset-bottom));
  }

  .__nswiki-composer textarea {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .__nswiki-btn,
  .__nswiki-panel,
  .__nswiki-icon-btn,
  .__nswiki-start-action,
  .__nswiki-send,
  .__nswiki-panel > .__nswiki-header > *,
  .__nswiki-panel > .__nswiki-content,
  .__nswiki-panel > .__nswiki-composer,
  .md-header,
  .md-container,
  .md-sidebar--secondary {
    transition: none;
  }

  .__nswiki-thinking span {
    animation: none;
    opacity: 0.65;
  }
}
