.nora-ai {
  --nora-panel-width: calc(100vw - 3.2rem);
  --nora-panel-width: min(42rem, calc(100vw - 3.2rem));
  --nora-border: rgba(var(--color-foreground), 0.14);
  --nora-border-strong: rgba(var(--color-foreground), 0.22);
  --nora-bg: rgb(var(--color-background));
  --nora-text: rgb(var(--color-foreground));
  --nora-muted: rgba(var(--color-foreground), 0.66);
  --nora-soft: rgba(var(--color-foreground), 0.055);
  --nora-soft-strong: rgba(var(--color-foreground), 0.095);
  --nora-shadow: 0 2.4rem 7rem rgba(var(--color-shadow), 0.18);
  display: block;
  pointer-events: none;
}

.nora-ai__launcher,
.nora-ai__panel,
.nora-ai__overlay {
  font-family: var(--font-body-family);
}

.nora-ai__launcher {
  position: fixed;
  right: 1.8rem;
  bottom: 1.8rem;
  right: max(1.8rem, env(safe-area-inset-right));
  bottom: max(1.8rem, env(safe-area-inset-bottom));
  z-index: 11000;
  display: grid;
  gap: 0.2rem;
  pointer-events: auto;
  max-width: calc(100vw - 3.6rem);
  max-width: min(28rem, calc(100vw - 3.6rem));
  padding: 1.3rem 1.6rem;
  border: 0.1rem solid rgba(var(--color-foreground), 0.28);
  border-radius: 0.8rem;
  border-radius: min(var(--buttons-radius), 0.8rem);
  background: var(--nora-text);
  color: var(--nora-bg);
  box-shadow: 0 1.2rem 3rem rgba(var(--color-shadow), 0.22);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.nora-ai__launcher:hover,
.nora-ai__launcher:focus-visible {
  transform: translateY(-0.2rem);
  box-shadow: 0 1.5rem 3.6rem rgba(var(--color-shadow), 0.28);
}

.nora-ai__launcher-main {
  font-family: var(--font-heading-family);
  font-size: 1.35rem;
  line-height: 1.2;
}

.nora-ai__launcher-sub {
  max-height: 0;
  overflow: hidden;
  font-size: 1.15rem;
  line-height: 1.35;
  color: rgba(var(--color-background), 0.78);
  opacity: 0;
  transition: max-height 180ms ease, opacity 180ms ease;
}

.nora-ai__launcher:hover .nora-ai__launcher-sub,
.nora-ai__launcher:focus-visible .nora-ai__launcher-sub {
  max-height: 4rem;
  opacity: 1;
}

.nora-ai.is-open .nora-ai__launcher {
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.6rem);
}

.nora-ai__overlay {
  position: fixed;
  inset: 0;
  z-index: 10999;
  background: rgba(var(--color-foreground), 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.nora-ai.is-open .nora-ai__overlay {
  opacity: 1;
  pointer-events: auto;
}

.nora-ai__panel {
  position: fixed;
  right: 1.8rem;
  bottom: 1.8rem;
  right: max(1.8rem, env(safe-area-inset-right));
  bottom: max(1.8rem, env(safe-area-inset-bottom));
  z-index: 11000;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  width: var(--nora-panel-width);
  max-height: 82vh;
  max-height: min(82vh, 72rem);
  max-height: min(82dvh, 72rem);
  border: 0.1rem solid var(--nora-border);
  border-radius: 0.8rem;
  border-radius: min(var(--popup-corner-radius), 0.8rem);
  background: var(--nora-bg);
  color: var(--nora-text);
  box-shadow: var(--nora-shadow);
  overflow: hidden;
  transform: translateX(1.4rem) translateY(1.4rem);
  opacity: 0;
  pointer-events: none;
  transition: transform 260ms ease, opacity 220ms ease;
}

.nora-ai.is-open .nora-ai__panel {
  transform: translateX(0) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.nora-ai__sheet-handle {
  display: none;
}

.nora-ai__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.2rem;
  padding: 1.8rem 1.8rem 1.2rem;
  border-bottom: 0.1rem solid var(--nora-border);
}

.nora-ai__identity {
  min-width: 0;
}

.nora-ai__eyebrow,
.nora-ai__subtitle,
.nora-ai__mode,
.nora-ai__info p,
.nora-ai__message p {
  margin: 0;
}

.nora-ai__eyebrow {
  font-family: var(--font-heading-family);
  font-size: 1.55rem;
  line-height: 1.2;
  color: var(--nora-text);
}

.nora-ai__subtitle {
  margin-top: 0.3rem;
  font-size: 1.16rem;
  line-height: 1.35;
  color: var(--nora-muted);
}

.nora-ai__header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.nora-ai__icon-button {
  display: inline-grid;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  border: 0.1rem solid var(--nora-border);
  border-radius: 999rem;
  background: transparent;
  color: var(--nora-text);
  font: inherit;
  line-height: 1;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.nora-ai__icon-button:hover,
.nora-ai__icon-button:focus-visible {
  border-color: var(--nora-border-strong);
  background: var(--nora-soft);
}

.nora-ai__info {
  margin: 1.2rem 1.8rem 0;
  padding: 1.2rem;
  border: 0.1rem solid var(--nora-border);
  border-radius: 0.8rem;
  background: var(--nora-soft);
  font-size: 1.22rem;
  line-height: 1.5;
  color: var(--nora-muted);
}

.nora-ai__info-title {
  margin-bottom: 0.4rem;
  color: var(--nora-text);
  font-family: var(--font-heading-family);
}

.nora-ai__mode {
  padding: 1rem 1.8rem 0;
  font-size: 1.08rem;
  line-height: 1.35;
  color: var(--nora-muted);
}

.nora-ai__messages {
  display: grid;
  align-content: start;
  gap: 1rem;
  min-height: 20rem;
  padding: 1.4rem 1.8rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.nora-ai__message {
  display: grid;
  gap: 0.8rem;
  max-width: 92%;
  font-size: 1.33rem;
  line-height: 1.5;
}

.nora-ai__message--user {
  justify-self: end;
  max-width: 84%;
}

.nora-ai__message-body {
  padding: 1rem 1.15rem;
  border: 0.1rem solid var(--nora-border);
  border-radius: 0.8rem;
  background: var(--nora-soft);
}

.nora-ai__message--user .nora-ai__message-body {
  background: var(--nora-text);
  color: var(--nora-bg);
  border-color: var(--nora-text);
}

.nora-ai__message--bot .nora-ai__message-body {
  background: transparent;
}

.nora-ai__message-body p + p {
  margin-top: 0.75rem;
}

.nora-ai__quick-actions {
  display: flex;
  gap: 0.7rem;
  padding: 0 1.8rem 1.2rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.nora-ai__chip {
  flex: 0 0 auto;
  min-height: 3.4rem;
  padding: 0.75rem 1.05rem;
  border: 0.1rem solid var(--nora-border);
  border-radius: 0.8rem;
  border-radius: min(var(--buttons-radius), 0.8rem);
  background: transparent;
  color: var(--nora-text);
  font: inherit;
  font-size: 1.18rem;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.nora-ai__chip:hover,
.nora-ai__chip:focus-visible {
  border-color: var(--nora-border-strong);
  background: var(--nora-soft);
}

.nora-ai__form {
  padding: 1.2rem 1.8rem 1.6rem;
  border-top: 0.1rem solid var(--nora-border);
}

.nora-ai__input-label {
  display: block;
  margin-bottom: 0.65rem;
  color: var(--nora-muted);
  font-size: 1.08rem;
  line-height: 1.3;
}

.nora-ai__input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 0.8rem;
}

.nora-ai__input {
  width: 100%;
  min-height: 4.4rem;
  max-height: 12rem;
  resize: none;
  padding: 1.1rem 1.2rem;
  border: 0.1rem solid var(--nora-border-strong);
  border-radius: 0.8rem;
  border-radius: min(var(--inputs-radius), 0.8rem);
  background: var(--nora-bg);
  color: var(--nora-text);
  font: inherit;
  font-size: 1.34rem;
  line-height: 1.35;
}

.nora-ai__send {
  min-height: 4.4rem;
  padding: 0 1.35rem;
  border: 0.1rem solid var(--nora-text);
  border-radius: 0.8rem;
  border-radius: min(var(--buttons-radius), 0.8rem);
  background: var(--nora-text);
  color: var(--nora-bg);
  font: inherit;
  font-size: 1.24rem;
  cursor: pointer;
}

.nora-ai__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.nora-ai__product-card {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1rem;
  padding: 1rem;
  border: 0.1rem solid var(--nora-border);
  border-radius: 0.8rem;
  background: var(--nora-soft);
}

.nora-ai__product-image {
  width: 7rem;
  aspect-ratio: 1;
  object-fit: contain;
  border-radius: 0.6rem;
  background: rgba(var(--color-background), 0.75);
}

.nora-ai__product-copy {
  min-width: 0;
}

.nora-ai__product-title {
  margin: 0;
  font-family: var(--font-heading-family);
  font-size: 1.22rem;
  line-height: 1.25;
}

.nora-ai__product-meta {
  margin: 0.35rem 0 0;
  color: var(--nora-muted);
  font-size: 1.08rem;
  line-height: 1.35;
}

.nora-ai__product-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.nora-ai__product-actions .button,
.nora-ai__product-actions .button--secondary {
  min-height: 3.2rem;
  min-width: 0;
  padding: 0 1rem;
  font-size: 1.08rem;
  line-height: 1.2;
}

.nora-ai__product-actions .button::after,
.nora-ai__product-actions .button::before {
  display: none;
}

.nora-ai__handoff {
  display: grid;
  gap: 0.8rem;
  padding: 1rem;
  border: 0.1rem solid var(--nora-border);
  border-radius: 0.8rem;
  background: var(--nora-soft);
}

.nora-ai__handoff a {
  color: var(--nora-text);
  text-decoration: underline;
  text-underline-offset: 0.2rem;
}

@media screen and (max-width: 749px) {
  .nora-ai__launcher {
    right: 1.4rem;
    bottom: 1.4rem;
    right: max(1.4rem, env(safe-area-inset-right));
    bottom: max(1.4rem, env(safe-area-inset-bottom));
    max-width: calc(100vw - 2.8rem);
    max-width: min(23rem, calc(100vw - 2.8rem));
    padding: 1.15rem 1.35rem;
  }

  .nora-ai__launcher-sub {
    display: none;
  }

  .nora-ai__panel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 1.2rem 1.2rem 0 0;
    padding-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
  }

  .nora-ai.is-open .nora-ai__panel {
    transform: translateY(0);
  }

  .nora-ai__sheet-handle {
    display: block;
    justify-self: center;
    width: 4.8rem;
    height: 0.4rem;
    margin-top: 0.8rem;
    border-radius: 999rem;
    background: var(--nora-border-strong);
  }

  .nora-ai__header {
    padding: 1.3rem 1.5rem 1rem;
  }

  .nora-ai__messages {
    min-height: 24rem;
    padding: 1.2rem 1.5rem;
  }

  .nora-ai__quick-actions {
    padding-right: 1.5rem;
    padding-left: 1.5rem;
  }

  .nora-ai__form {
    padding: 1rem 1.5rem 1.3rem;
  }

  .nora-ai__product-card {
    grid-template-columns: 6rem minmax(0, 1fr);
  }

  .nora-ai__product-image {
    width: 6rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nora-ai__launcher,
  .nora-ai__panel,
  .nora-ai__overlay,
  .nora-ai__chip,
  .nora-ai__icon-button {
    transition: none;
  }
}
