:root {
  --nl-bg: #f6f7fb;
  --nl-panel: rgba(255, 255, 255, 0.72);
  --nl-border: rgba(14, 24, 42, 0.12);
  --nl-text: rgba(14, 24, 42, 0.92);
  --nl-subtext: rgba(14, 24, 42, 0.68);
  --nl-shadow: 0 18px 60px rgba(10, 18, 40, 0.10);

  --nl-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
}

/* =========================================================
   Instance palette (JS overwrites these from work_color)
   ========================================================= */

.nl-ai-prompt-wrap {
  --nl-work-bg: rgba(31, 111, 255, 0.10);
  --nl-work-border: rgba(31, 111, 255, 0.22);
  --nl-work-wash-soft: rgba(214, 229, 255, 0.28);
  --nl-work-wash-strong: rgba(199, 219, 255, 0.38);
  --nl-work-dot-a: rgba(25, 82, 195, 0.78);
  --nl-work-dot-b: rgba(60, 140, 255, 0.78);

  max-width: 1050px;
  margin: 0 auto;
  padding: 24px 0;
  color: var(--nl-text);
}

/* =========================================================
   Input shell
   ========================================================= */

.nl-ai-prompt-wrap .nl-ai-input {
  width: 100%;
  background: rgb(255 255 255 / 98%);
  border: 1px solid var(--nl-border);
  border-radius: 14px;

  padding: 18px 18px;
  min-height: 74px;

  display: flex;
  align-items: center;
  gap: 14px;

  box-shadow: var(--nl-shadow);

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

/* =========================================================
   Prompt typing
   ========================================================= */

.nl-ai-prompt-wrap .nl-ai-placeholder {
  font-family: var(--nl-mono);
  font-size: 18px;
  line-height: 1.4;

  color: var(--nl-subtext);

  display: inline-flex;
  align-items: center;
  gap: 10px;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  flex: 1 1 auto;
  min-width: 0;
}

.nl-ai-prompt-wrap .nl-ai-typed {
  display: inline-block;
  min-width: 0;
}

.nl-ai-prompt-wrap .nl-ai-caret {
  width: 10px;
  height: 22px;
  background: rgba(14, 24, 42, 0.55);
  border-radius: 2px;

  animation: nlBlink 1.05s steps(1, end) infinite;
  flex: 0 0 auto;
}

@keyframes nlBlink {
  50% { opacity: 0; }
}

/* =========================================================
   Submit base (idle square)
   ========================================================= */

.nl-ai-prompt-wrap .nl-submit {
  flex: 0 0 auto;

  height: 44px;
  width: 46px;

  border-radius: 12px;
  border: 1px solid var(--nl-border);

  background: rgba(255, 255, 255, 0.55);

  display: inline-flex;
  align-items: center;
  justify-content: center;

  position: relative;
  overflow: hidden;

  box-shadow: 0 10px 28px rgba(10, 18, 40, 0.08);

  /* default morph timing */
  transition:
    width 560ms cubic-bezier(0.18, 0.98, 0.18, 1),
    border-radius 320ms cubic-bezier(0.18, 0.98, 0.18, 1),
    background 320ms ease,
    border-color 320ms ease,
    box-shadow 320ms ease,
    transform 320ms ease;
}

/* Keep layers predictable across browsers */
.nl-ai-prompt-wrap .nl-submit::after { z-index: 0; }
.nl-ai-prompt-wrap .nl-icon,
.nl-ai-prompt-wrap .nl-submit-shape { z-index: 1; }
.nl-ai-prompt-wrap .nl-icon-check { z-index: 2; }

/* icons */

.nl-ai-prompt-wrap .nl-icon {
  width: 18px;
  height: 18px;

  display: block;

  opacity: 0.92;
  transform: translateY(0) scale(1);

  transition:
    opacity 260ms ease,
    transform 420ms cubic-bezier(0.18, 0.98, 0.18, 1);
}

/*
  Robust centering for incognito / Safari / odd GPU states:
  Use left/top 50% and translate, not inset+margin auto.
*/
.nl-ai-prompt-wrap .nl-icon-check {
  position: absolute;
  left: 50%;
  top: 50%;

  width: 20px;
  height: 20px;

  display: block;

  opacity: 0;

  transform: translate(-50%, -50%) scale(0.96);
  transform-origin: 50% 50%;
}

/* Pill wash layer (only visible when working) */
.nl-ai-prompt-wrap .nl-submit::after {
  content: "";
  position: absolute;
  inset: 8px 10px;

  border-radius: 999px;

  background:
    linear-gradient(
      135deg,
      var(--nl-work-wash-soft),
      var(--nl-work-wash-strong)
    );

  opacity: 0;
  transform: scale(0.92);

  transition:
    opacity 240ms ease,
    transform 520ms cubic-bezier(0.18, 0.98, 0.18, 1);
}

/* =========================================================
   Dots
   ========================================================= */

.nl-ai-prompt-wrap .nl-submit-shape {
  position: absolute;
  inset: 0;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  opacity: 0;
  transform: translateY(2px);

  transition:
    opacity 240ms ease,
    transform 520ms cubic-bezier(0.18, 0.98, 0.18, 1);

  pointer-events: none;
}

.nl-ai-prompt-wrap .nl-submit-dot {
  width: 8px;
  height: 8px;

  border-radius: 999px;

  background: var(--nl-work-dot-a);

  animation: nlDot 1100ms infinite ease-in-out;
}

.nl-ai-prompt-wrap .nl-submit-dot:nth-child(2) {
  background: var(--nl-work-dot-b);
  animation-delay: 180ms;
}

.nl-ai-prompt-wrap .nl-submit-dot:nth-child(3) {
  animation-delay: 360ms;
}

@keyframes nlDot {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  50% {
    transform: translateY(-3px);
    opacity: 0.98;
  }
}

/* =========================================================
   WORKING (square -> pill morph)
   ========================================================= */

.nl-ai-prompt-wrap .nl-submit.is-working {
  width: 108px;
  border-radius: 999px;

  border-color: var(--nl-work-border);
  background: var(--nl-work-bg);
}

.nl-ai-prompt-wrap .nl-submit.is-working .nl-icon-send {
  opacity: 0;
  transform: translateY(2px) scale(0.88);
}

.nl-ai-prompt-wrap .nl-submit.is-working::after {
  opacity: 1;
  transform: scale(1);
}

.nl-ai-prompt-wrap .nl-submit.is-working .nl-submit-shape {
  opacity: 1;
  transform: translateY(0);
}

/* Ensure check stays hidden during working */
.nl-ai-prompt-wrap .nl-submit.is-working .nl-icon-check {
  opacity: 0;
}

/* =========================================================
   DONE (pill -> square, fast-radius return, clean green glass)
   ========================================================= */

/*
  Key fix: when returning to done, the box radius must revert faster
  than width, otherwise it looks like it is "catching up".
  We override transitions only for the done state.
*/
.nl-ai-prompt-wrap .nl-submit.is-done {
  width: 46px;
  border-radius: 12px;

  background: rgb(255 255 255 / 12%);
  border-color: #249b8e75;

  box-shadow: 0 10px 28px rgba(10, 18, 40, 0.08);

  transition:
    width 520ms cubic-bezier(0.18, 0.98, 0.18, 1),
    border-radius 180ms cubic-bezier(0.18, 0.98, 0.18, 1),
    background 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    transform 220ms ease;
}

/* Make sure wash and dots drop away quickly so the check is visible */
.nl-ai-prompt-wrap .nl-submit.is-done::after {
  opacity: 0;
  transform: scale(0.92);
  transition:
    opacity 140ms ease,
    transform 180ms ease;
}

.nl-ai-prompt-wrap .nl-submit.is-done .nl-submit-shape {
  opacity: 0;
  transform: translateY(2px);
  transition:
    opacity 140ms ease,
    transform 180ms ease;
}

.nl-ai-prompt-wrap .nl-submit.is-done .nl-icon-send {
  opacity: 0;
  transform: translateY(2px) scale(0.88);
}

/* Check: guaranteed visible, centered, subtle pop */
.nl-ai-prompt-wrap .nl-submit.is-done .nl-icon-check {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition:
    opacity 160ms ease,
    transform 220ms cubic-bezier(0.16, 1.08, 0.22, 1);
}

.nl-ai-prompt-wrap .nl-icon-check path {
  stroke: #249B8E;
}

/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 640px) {
  .nl-ai-prompt-wrap .nl-ai-input {
    padding: 16px 16px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
  }

  .nl-ai-prompt-wrap .nl-ai-placeholder {
    font-size: 15px;
    line-height: 1.35;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    align-items: flex-start;
  }
}

/* =========================================================
   Reduced motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  .nl-ai-prompt-wrap .nl-ai-caret { animation: none; }
  .nl-ai-prompt-wrap .nl-submit-dot { animation: none; }

  .nl-ai-prompt-wrap .nl-submit,
  .nl-ai-prompt-wrap .nl-submit::after,
  .nl-ai-prompt-wrap .nl-submit-shape,
  .nl-ai-prompt-wrap .nl-icon,
  .nl-ai-prompt-wrap .nl-icon-check {
    transition: none;
  }
}
/* =========================================================
   HARD OVERRIDE: DONE state icons (wins against global SVG rules)
   Put this at the very bottom of the CSS file
   ========================================================= */

.nl-ai-prompt-wrap .nl-submit.is-done{
  /* make the radius snap back faster than width */
  transition:
    width 520ms cubic-bezier(0.18, 0.98, 0.18, 1),
    border-radius 120ms cubic-bezier(0.18, 0.98, 0.18, 1),
    background 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    transform 220ms ease;
}

/* Kill send icon completely so it cannot "shine through" */
.nl-ai-prompt-wrap .nl-submit.is-done svg.nl-icon-send{
  opacity: 0 !important;
  visibility: hidden !important;
  display: none !important;
}

/* Force check icon visible and centered */
.nl-ai-prompt-wrap .nl-submit.is-done svg.nl-icon-check{
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;

  position: absolute !important;
  left: 50% !important;
  top: 50% !important;

  width: 20px !important;
  height: 20px !important;

  transform: translate(-50%, -50%) scale(1) !important;
  transform-origin: 50% 50% !important;

  z-index: 5 !important;
  pointer-events: none !important;
}

/* Override the inline stroke color from the SVG path */
.nl-ai-prompt-wrap .nl-submit.is-done svg.nl-icon-check path{
  stroke: #249B8E !important;
}

/* Ensure dots are hidden in done state */
.nl-ai-prompt-wrap .nl-submit.is-done .nl-submit-shape{
  opacity: 0 !important;
  visibility: hidden !important;
}
