.nex-widget {
  --nex-orange: #f7941d;
  --nex-ink: #000000;
  --nex-muted: #595959;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 880;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
}

.nex-widget *,
.nex-widget *::before,
.nex-widget *::after { box-sizing: border-box; }

.nex-widget button,
.nex-widget textarea { font: inherit; }

.nex-widget__toggle {
  display: flex;
  width: 60px;
  min-width: 60px;
  height: 60px;
  min-height: 60px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--nex-orange);
  color: var(--nex-ink);
  font-size: 0;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(249, 115, 22, .4);
  transition: background-color .3s ease, box-shadow .3s ease, transform .3s ease;
}

.nex-widget button.nex-widget__toggle {
  font-size: 0;
  line-height: 0;
}

.nex-widget__toggle::before {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  content: '';
  background: center / contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000000' d='M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2Zm0 14H6l-2 2V4h16v12Z'/%3E%3C/svg%3E");
}

.nex-widget__toggle:hover {
  background: #f7941d;
  box-shadow: 0 6px 25px rgba(249, 115, 22, .5);
  transform: scale(1.05);
}

.nex-widget__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  width: min(400px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 128px));
  overflow: hidden;
  flex-direction: column;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1px solid #dedbd6;
  border-radius: 22px;
  background: #fff;
  color: var(--nex-ink);
  box-shadow: 0 16px 64px rgba(0, 0, 0, .18);
}

.nex-widget__panel[hidden] { display: none; }

.nex-widget__header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  min-height: 0;
  margin: 0;
  padding: 18px 20px;
  border-bottom: 1px solid #ece9e4;
}

.nex-widget__header h2,
.nex-widget__header p { margin: 0; }
.nex-widget__header h2 { color: var(--nex-ink); font-size: 1rem; }
.nex-widget__header p { margin-top: 2px; color: var(--nex-muted); font-size: .76rem; }

.nex-widget__close {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--nex-ink);
  cursor: pointer;
}

.nex-widget__messages {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  flex-direction: column;
  gap: 12px;
  padding: 24px 20px;
}

.nex-widget__message {
  max-width: 92%;
  padding: 11px 13px;
  border-radius: 14px;
  font-size: .9rem;
  line-height: 1.55;
  white-space: normal;
  overflow-wrap: anywhere;
}

.nex-widget__message p { margin: 0; font: inherit; color: inherit; }
.nex-widget__message p + p,
.nex-widget__message p + ul,
.nex-widget__message p + ol,
.nex-widget__message ul + p,
.nex-widget__message ol + p,
.nex-widget__message ul + ol,
.nex-widget__message ol + ul,
.nex-widget__message ul + ul,
.nex-widget__message ol + ol { margin-top: 10px; }
.nex-widget__message ul,
.nex-widget__message ol { margin: 0; padding-left: 20px; }
.nex-widget__message ul { list-style: disc outside; }
.nex-widget__message ol { list-style: decimal outside; }
.nex-widget__message li { display: list-item; padding: 0; }
.nex-widget__message li + li { margin-top: 6px; }
.nex-widget__message strong { font-weight: 700; }
.nex-widget__links {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #d6d1c9;
}
.nex-widget__links:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.nex-widget__links a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #bba68b;
  border-radius: 8px;
  background: #fff3e2;
  text-decoration: underline;
}
.nex-widget__links a:hover { background: #ffe4bd; border-color: #89643a; }
.nex-widget__links a:focus-visible { outline: 2px solid var(--nex-ink); outline-offset: 2px; }

.nex-widget__message--assistant { align-self: flex-start; background: #f4f3f0; }
.nex-widget__message--user { align-self: flex-end; background: var(--nex-orange); color: var(--nex-ink); }
.nex-widget__message a { color: inherit; font-weight: 600; text-decoration-thickness: 1px; text-underline-offset: 3px; }

.nex-widget__form { padding: 14px 16px 16px; border-top: 1px solid #ece9e4; }
.nex-widget__form > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.nex-widget__input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.nex-widget__input-row textarea {
  width: 100%;
  min-height: 48px;
  max-height: 108px;
  resize: none;
  font-size: 16px;
  line-height: 24px;
  border: 1px solid #8a847b;
  border-radius: 12px;
  background: #fff;
  color: var(--nex-ink);
  padding: 11px 12px;
}

.nex-widget__send {
  min-width: 64px;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: var(--nex-orange);
  color: var(--nex-ink);
  font-weight: 800;
  cursor: pointer;
}

.nex-widget__send:disabled { cursor: not-allowed; opacity: .55; }
.nex-widget__retry {
  display: inline-flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 10px 14px;
  border: 1px solid #5f421f;
  border-radius: 10px;
  background: #fff3e2;
  color: var(--nex-ink);
  font: inherit;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.nex-widget__retry:hover { border-color: var(--nex-ink); background: #ffe4bd; }
.nex-widget__retry[hidden] { display: none; }
.nex-widget__verification,
.nex-widget__verification-host { display: contents; }
.nex-widget__verification--interactive {
  display: grid;
  gap: 10px;
  max-width: 100%;
  padding: 12px;
  border: 1px solid #d6d1c9;
  border-radius: 12px;
  background: #fffaf3;
  color: var(--nex-ink);
  font-size: .82rem;
  line-height: 1.45;
}
.nex-widget__verification p { margin: 0; }
.nex-widget__verification--interactive .nex-widget__verification-host {
  display: block;
  min-height: 140px;
  overflow-x: auto;
}
.nex-widget__status { min-height: 1.2em; margin: 7px 0 0; color: var(--nex-muted); font-size: .72rem; }

.nex-widget :focus-visible {
  outline: 2px solid #000;
  outline-offset: 3px;
}

.nex-widget__toggle[aria-expanded="true"] { visibility: hidden; }

@media (max-width: 600px) {
  .nex-widget { right: 16px; bottom: 16px; }
  .nex-widget__panel { bottom: 0; height: min(560px, calc(100dvh - 112px)); }
  .nex-widget__header { padding: 12px; }
  .nex-widget__messages { padding: 14px; }
}

@media (prefers-reduced-motion: no-preference) {
  .nex-widget__panel { animation: nex-panel-in .16s ease-out; transform-origin: bottom right; }
  @keyframes nex-panel-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
}

.nex-widget__privacy { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--nex-muted); font-size: .75rem; text-underline-offset: 3px; }
.nex-widget button.nex-widget__close { font-size: 0; line-height: 0; }
.nex-widget__close::before { content: '×'; font-size: 28px; line-height: 1; }
.nex-widget__close:hover, .nex-widget__privacy:hover { background: #f4f3f0; border-radius: 10px; }
.nex-widget__input-row textarea::placeholder { color: var(--nex-muted); opacity: 1; }
.nex-widget__status:empty { display: none; }
.nex-widget__suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.nex-widget__suggestion { min-height: 44px; border: 1px solid #c8c1b7; border-radius: 24px; padding: 10px 14px; background: #fff; color: #000; font-size: .8rem; cursor: pointer; }
.nex-widget__suggestion:hover { background: #fff4e6; border-color: #8a847b; }
.nex-widget__messages { overscroll-behavior: contain; }
.nex-widget__header, .nex-widget__form { flex-shrink: 0; }
@media (prefers-reduced-motion: reduce) {
  .nex-widget__toggle { transition: none; }
}

.nex-widget__input-row textarea:focus-visible { outline: 1px solid #000; outline-offset: 0; border-color: #000; }
